dispelthemyth
Well-known Member
- Joined
- Mar 16, 2006
- Messages
- 663
- Office Version
-
- 365
- Platform
-
- Windows
I am currently looking for a better method for iterating through lots of large areas with lots of redundant columns
e.g.
Used range = A1:ZA1000, 99% of the data is in column A and B with zome in ZA
Used Range = A10:DA15000, there is data in A - Z, BA, BD and DA, most columns go up to row 100 but BA and DA go to row 15000
Used Range = D10:HA1000, most data is in columns D, E, Z, AA and HA
As you can see the majority of the cells being searched are blank
The code i am using at the minute checks the remaining colums in each row to see if they are blank and if they are it iterates to the next row
Does anyone know of any code that goes through ranges quicker?
e.g.
Used range = A1:ZA1000, 99% of the data is in column A and B with zome in ZA
Used Range = A10:DA15000, there is data in A - Z, BA, BD and DA, most columns go up to row 100 but BA and DA go to row 15000
Used Range = D10:HA1000, most data is in columns D, E, Z, AA and HA
As you can see the majority of the cells being searched are blank
The code i am using at the minute checks the remaining colums in each row to see if they are blank and if they are it iterates to the next row
Code:
Set rngAny = wkbToImport.Sheets(wksSheet.name).UsedRange
i = rngAny.Rows.Count
j = rngAny.Columns.Count
iCol = 1
With wkbToImport.Sheets(wksSheet.name)
For iRow = 1 To i
For iCol = 1 To j
On Error Resume Next
'Check if the rest of the section can be skipped, if it can iterate to the next row
If .Range(.Cells(iRow, iCol), .Cells(iRow, j)).SpecialCells(xlCellTypeBlanks).Count = .Range(.Cells(iRow, iCol), .Cells(iRow, j)).Count Then
Exit For
Else
'Do something
Last edited: