Dim User As New
New Member
- Joined
- May 23, 2011
- Messages
- 4
Hi All,
I have some code that checks a series of worksheets in a workbook for specific errors based on indicators in the field heading and then outputs dynamic hyperlinks to the cells with trapped errors in an error report. I'm having a problem with the Do While loop that I'm using to comb each applicable column though. Right now the loop is going while the next 25 rows in the column are not empty, but I want the loop to STOP when it reaches a row that is completely empty (all adjacent cells) instead.
Here is my code so far:
' Loop through all worksheets except "Instructions" and "EDE_Appendix"
For Each Worksheet_Loop In ThisWorkbook.Worksheets
If (Worksheet_Loop.Name <> "Instructions" _
And Worksheet_Loop.Name <> "EDE_Appendix") Then
' Select starting range on active worksheet and define right-most column
ActiveSheet.Range("A9").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.End(xlToRight).Select
i = ActiveCell.Column
ActiveSheet.Range("A9").Select
' Loop through the applicable columns
For Column_Count = 0 To i
' Loop through the active column
Active_Row = ActiveCell.Row
Active_Column = ActiveCell.Column
Do While Not (IsEmpty(Cells(Active_Row, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 1, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 2, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 3, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 4, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 5, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 6, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 7, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 8, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 9, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 10, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 11, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 12, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 13, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 14, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 15, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 16, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 17, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 18, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 19, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 20, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 21, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 22, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 23, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 24, ActiveCell.Column)) = False)
ActiveCell.Offset(1, 0).Select
Active_Row = ActiveCell.Row
Active_Column = ActiveCell.Column
Header_Value = Cells(9, Active_Column).Value
' IF field values need to be unique but are not THEN render cell blue
' IF actual length is greater than expected length THEN render cell green
' IF data type mismatch exists THEN render cell yellow
' IF field values are required but are null THEN render cell red
Loop
Range("A9").Offset(0, Column_Count).Select
Next Column_Count
ActiveSheet.Range("A8").Select
End If
Next
I've tried multiple approaches including referencing specific ranges and different variations of the loop to no avail... There has to be a more efficient way of going about this, but I keep getting caught in the loop offsetting to the next row... Any suggestions that will work with the rest of my code?
I'm using Excel 2010.
Thank you in advance!
-DUAN
I have some code that checks a series of worksheets in a workbook for specific errors based on indicators in the field heading and then outputs dynamic hyperlinks to the cells with trapped errors in an error report. I'm having a problem with the Do While loop that I'm using to comb each applicable column though. Right now the loop is going while the next 25 rows in the column are not empty, but I want the loop to STOP when it reaches a row that is completely empty (all adjacent cells) instead.
Here is my code so far:
' Loop through all worksheets except "Instructions" and "EDE_Appendix"
For Each Worksheet_Loop In ThisWorkbook.Worksheets
If (Worksheet_Loop.Name <> "Instructions" _
And Worksheet_Loop.Name <> "EDE_Appendix") Then
' Select starting range on active worksheet and define right-most column
ActiveSheet.Range("A9").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.End(xlToRight).Select
i = ActiveCell.Column
ActiveSheet.Range("A9").Select
' Loop through the applicable columns
For Column_Count = 0 To i
' Loop through the active column
Active_Row = ActiveCell.Row
Active_Column = ActiveCell.Column
Do While Not (IsEmpty(Cells(Active_Row, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 1, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 2, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 3, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 4, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 5, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 6, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 7, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 8, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 9, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 10, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 11, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 12, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 13, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 14, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 15, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 16, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 17, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 18, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 19, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 20, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 21, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 22, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 23, ActiveCell.Column)) = False _
And Not IsEmpty(Cells(Active_Row + 24, ActiveCell.Column)) = False)
ActiveCell.Offset(1, 0).Select
Active_Row = ActiveCell.Row
Active_Column = ActiveCell.Column
Header_Value = Cells(9, Active_Column).Value
' IF field values need to be unique but are not THEN render cell blue
' IF actual length is greater than expected length THEN render cell green
' IF data type mismatch exists THEN render cell yellow
' IF field values are required but are null THEN render cell red
Loop
Range("A9").Offset(0, Column_Count).Select
Next Column_Count
ActiveSheet.Range("A8").Select
End If
Next
I've tried multiple approaches including referencing specific ranges and different variations of the loop to no avail... There has to be a more efficient way of going about this, but I keep getting caught in the loop offsetting to the next row... Any suggestions that will work with the rest of my code?
I'm using Excel 2010.
Thank you in advance!
-DUAN
Last edited: