jbenfrancis1
New Member
- Joined
- Feb 22, 2022
- Messages
- 11
- Office Version
- 365
- 2016
- Platform
- Windows
Hi, I have a master workbook and a macro that searches for a file name and opens it once found. The files being found all have a table in them with the left most column in column B but the start row changes from file to file. All files being found either have "Affiliation →" or "Line of Business →" in column b which is the start of the table.
I am trying to write a macro that will look at the active workbook and search column b for either "Affiliation → " or "Line of Business →". Once it finds the cell in column b with that text string, I want it to ctrl+shift+down and ctrl+shift+right to copy that cata. I can then finish the macro to activate my master book and paste data.
I tried this orignally but it lonly looks for "Affiliation" and doesnt account for speacial character arrow
I am trying to write a macro that will look at the active workbook and search column b for either "Affiliation → " or "Line of Business →". Once it finds the cell in column b with that text string, I want it to ctrl+shift+down and ctrl+shift+right to copy that cata. I can then finish the macro to activate my master book and paste data.
I tried this orignally but it lonly looks for "Affiliation" and doesnt account for speacial character arrow
VBA Code:
Sub Copy()
Dim wb1 as Workbook
Dim wb2 as Workbook
wb1 = ThisWorkbook
wb2 = "Data.xlsx"
Dim AffCol As Range
Dim Aff As Range
Dim PasteCell As Range
Set AffCol = sb2.Sheet1.Range("B:B")
For Each Aff In AffCol
If wb1.Sheet5.Range("A2") = "" Then
Set PasteCell = wb1.Sheet5.Range("A2")
Else
Set PasteCell = ws1.Sheet5.Range("A1").End(xlDown).Offset(1, 0)
End If
If Aff = "Affiliation" Then Range(Aff.End(xlToBottom), Aff.End(xlToRight)).Copy PasteCell
Next Aff
End Sub