Francois084
New Member
- Joined
- Jun 23, 2022
- Messages
- 10
- Office Version
- 2019
- Platform
- Windows
Hi
I'm having trouble with my offset
I used my previous code and changed it so that it look for a specific word and search over multiple worksheets
It does find the word and copies it over to the new sheet.
but when it find the 2nd one it overwrites the previous line on the new sheet
Thank you for helping
I'm having trouble with my offset
I used my previous code and changed it so that it look for a specific word and search over multiple worksheets
It does find the word and copies it over to the new sheet.
but when it find the 2nd one it overwrites the previous line on the new sheet
Thank you for helping
VBA Code:
Sub OtherSearchString()
Dim iIndex As Integer
Dim ws As Excel.Worksheet
Dim lr As Long
Dim r As Long
Dim C As Range
Dim Target As Worksheet
b = 0
Set Target = ActiveWorkbook.Worksheets("Supp or Dept")
For iIndex = 1 To ActiveWorkbook.Worksheets.Count
Set ws = Worksheets(iIndex)
ws.Activate
' Find last row in column E on Source sheet
lr = ws.Cells(Rows.Count, "C").End(xlUp).Row
' Loop through each row in column E backwards
For r = lr To 1 Step -1
' Build "c" range
Set C = ws.Range("C" & r)
' Proceed with rest of your code
If C Like "*SUPP*" Then
C.EntireRow.copy
Target.Range("A" & Rows.Count).End(xlDown).Offset(1).PasteSpecial
C.EntireRow.Delete
ElseIf C Like "*DEPT*" Then
C.EntireRow.copy
b = Target.Range("A" & Rows.Count).End(xlUp).Offset(3).PasteSpecial
b = b + 1
C.EntireRow.Delete
End If
Next r
Next iIndex
End Sub