View Single Post
 
Old 08-11-2022, 12:06 AM
shanshan89 shanshan89 is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2022
Posts: 17
shanshan89 is on a distinguished road
Smile

Quote:
Originally Posted by Guessed View Post
Since you are adding the value
arrData1(0, lngIndex)

wouldn't it make sense to test if that is null rather than the value of
UBound(arrData1, 2)
which won't change during each step of the For/Next loop
Dear Guessed,

Thanks for your reply. Don't really get what you mean. But now I'm trying to remove all blank fields from the source data (excel) instead. However, instead of removing blank fields from just 1 sheet, I would like to loop through the entire worksheet and remove every blank field from every sheet. My excel vba code is as follows. However, this code only allows blank fields from the 'active sheet' to be removed whereas the blank fields from other sheets will not be removed. Able to advise?

Sub WorksheetLoop()

' Declare Current as a worksheet object variable.
Dim Current As Worksheet

' Loop through all of the worksheets in the active workbook.
For Each Current In Worksheets

' Insert your code here.
On Error Resume Next
Range("A2:A" & Current.UsedRange.Rows.Count).SpecialCells(xlCellT ypeBlanks).EntireRow.Delete

' This line displays the worksheet name in a message box.
MsgBox Current.Name

Next

End Sub
Reply With Quote