View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Vb Code not working

Remove the "exit for"

IIRC, you're original code printed the first one that matched and didn't print
anymore.

(But it's been a couple of days <bg.)

bob wrote:

This code only checks the first range and stops or prints. What is wrong? I would like it to continue to all 20 ranges check and skip or print.
Can you tell what is missing?

Private Sub CommandButton34_Click()
Dim iRow As Long
Dim HowMany As Long

HowMany = 20

With ActiveSheet
For iRow = 52 To (32 * HowMany - 1) + 52 Step 32
If IsNumeric(.Cells(iRow + 3, "I").Value) Then
If .Cells(iRow + 3, "I").Value 0 Then
.Cells(iRow, "A").Resize(16, 9).PrintPreview
'.printout when you're done checking
Exit For
End If
End If
Next iRow
End With

Range("A1").Select
End Sub

Thank you very much.


--

Dave Peterson