How can I remove the 2 columns or not being copied over from one sheet to the other one? Here is the Macro I am using in order to copy over data.
Thank you.
The 2 that I do not want copied over are "L,M".
Sub Collate_Sheets()
strSourceSheet = "inventory-total"
Set wsSource = ActiveWorkbook.Sheets(strSourceSheet)
For lngRow = 2 To wsSource.Cells(65536, "L").End(xlUp).Row
wsName = wsSource.Cells(lngRow, "M").Value
boolNewWS = True
'Check if the worksheet with the code exists
For Each wsTarget In ActiveWorkbook.Sheets
If LCase(wsTarget.Name) <> LCase(strSourceSheet) And LCase(wsTarget.Name) = LCase(wsName) Then
boolNewWS = False
End If
Next
If boolNewWS = True Then
Set wsTarget = ActiveWorkbook.Sheets.Add()
wsTarget.Name = wsName
wsTarget.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
wsSource.Rows(1).Copy Destination:=wsTarget.Rows(1)
Else
Set wsTarget = ActiveWorkbook.Sheets(wsName)
End If
wsSource.Rows(lngRow).Copy Destination:=wsTarget.Rows(wsTarget.Cells(65536, "L").End(xlUp).Row + 1)
Next
MsgBox "Done"
End Sub
Bookmarks