jakeman
Active Member
- Joined
- Apr 29, 2008
- Messages
- 325
- Office Version
- 365
- Platform
- Windows
Hello everyone - I have a loop statement that's not working correctly and I'm stuck.
What I'm attempting to do is loop through an entire range of values in a single column and where a cell in that range has a value of 1, I return a value from a column adjacent to that column (3 columns away, technically). So far I'm getting some values returned but at the first change of value in the column I'm evaluating, the loop breaks down. Basically, the first two rows in the range are returning fine because they are both 1's, but on the 3rd row the value is a two and my loop doesn't skip over this and find the next value of 1.
Here is my code:
I'm not sure what syntax is required to tell the loop to move to the next cell in range if value not equal to 1.
What I'm attempting to do is loop through an entire range of values in a single column and where a cell in that range has a value of 1, I return a value from a column adjacent to that column (3 columns away, technically). So far I'm getting some values returned but at the first change of value in the column I'm evaluating, the loop breaks down. Basically, the first two rows in the range are returning fine because they are both 1's, but on the 3rd row the value is a two and my loop doesn't skip over this and find the next value of 1.
Here is my code:
Code:
Set rng = Sheets("Roster").Range("AC6:AC155") 'This column looks at Member Status and returns 1 for Members in good standing and 2 for members not active
x = Application.Dialogs(xlDialogPrinterSetup).Show
For Each cell In rng
If cell.Value = 1 Then
Sheets("Letter").Range("B10") = cell.Offset(0, -3)
End If
ActiveSheet.PageSetup.Orientation = xlPortrait
ActiveSheet.PrintOut
Next cell
I'm not sure what syntax is required to tell the loop to move to the next cell in range if value not equal to 1.