bradyboyy88
Well-known Member
- Joined
- Feb 25, 2015
- Messages
- 562
I have a workbook and the first row is used for markers of important columns. The identifier basically lets me know there is important data in that column. I have been trying to shortening my looping of cells through used range but I am weak on it. First I want to loop through the first row of the usedrange which I assume is row 1 and then build my range of important columns. Then I want to loop through each of the cells of this range. to collect and do other modifications too. So how do I efficiently loop through in this method. Here is my code so far:
Code:
Sub copyTracker()
Dim xlApp As Application
Dim wb As Workbook
Dim filepath As String
Dim cell As Range
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
filepath = "C:\path\import.xlsx"
xlApp.AskToUpdateLinks = False
xlApp.DisplayAlerts = False
Set wb = xlApp.Workbooks.Open(Filename:=filepath, ReadOnly:=True)
xlApp.DisplayAlerts = True
xlApp.AskToUpdateLinks = True
For Each cell In wb.Sheets("Sheet1").UsedRange.Rows(1)
'not sure how but I to take the intersect of the the UsedRange and these columns with markers and assign them to another range I can foreach through.
Next cell
End Sub