Kemidan2014
Board Regular
- Joined
- Apr 4, 2022
- Messages
- 226
- Office Version
- 365
- Platform
- Windows
I was advised to change the range of a macro i am using on open to a reasonable number of rows instead of calling out for the entire column
Below is a snippet of the code where columns are referenced
how would i go about setting each of the columns i have listed in the code below to only go to ROw 3000 for each? for instance i had A:B,... which is looking at all of A and B column if i did A:B3000 would it look at ALL of Column A and then only B1 to B3000? or would it limit column A to 3000 as well?
Below is a snippet of the code where columns are referenced
how would i go about setting each of the columns i have listed in the code below to only go to ROw 3000 for each? for instance i had A:B,... which is looking at all of A and B column if i did A:B3000 would it look at ALL of Column A and then only B1 to B3000? or would it limit column A to 3000 as well?
VBA Code:
Set rng = srcSH.Range("A:B,D:E,H:K,O:O,Q:AB,AH:AH")
For Each c In srcSH.Range("A2", srcSH.Range("A" & Rows.Count).End(3))
Set f = desSH.Range("A:A").Find(c.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then nRow = f.Row Else nRow = desSH.Range("A" & Rows.Count).End(3).Row + 1
j = 0
For Each col In rng.Columns
n = col.Column
j = j + 1
desSH.Cells(nRow, j).Value = srcSH.Cells(c.Row, n).Value
Next
Next