Hi,
I need to edit the code below to find the word "Volume" in the header cell (the code can search the entire sheet), copy that entire column, move it to the first column after the last used column of data in the same sheet, rename it "Total Volume" and delete the original "volume" column. I need this done on every worksheet in the workbook.
The incomplete code I have so far is below. It copies a the correct column on a random(EDIT: It copies the column from the LAST worksheet with the word "Volume" so it's looping to the end and copying the last instance) worksheet, though and just stops, so the loop must be wrong.
![]()
Sub VolumeMove() Dim ws As Worksheet Dim last_column As Integer For Each ws In ActiveWorkbook.Worksheets last_column = ws.Cells.find("*", [A1], , , xlByColumns, xlPrevious).Column 'On Error Resume Next 'Will continue if an error results 'ws.Range("A1") = ws.Name For iloop = 1 To last_column If InStr(1, ws.Cells(1, iloop), "Volume", vbTextCompare) <> 0 Then 'ws.Columns(iloop).Select 'Selection.Copy With ws.Columns(iloop) .Copy End With End If Next iloop Next ws End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks