K
Karen53
Hi,
I need to find 4 cells in the same column that have the same value, 4. I
need to save the row so I can use it as the end of my print range.
Here is what I have so far but it's not working. Can anyone help?
Sub PrintDoc()
Dim LastRow As Integer 'Last Row of Printing Range
Dim FirstAddress As Range 'First found occurance of a match
Dim NextAddress As Range ' Next occurance of a match
Dim X As Integer 'counter
X = 0 'set counter to 0
With ActiveSheet.Range("E36:E336")
Set c = .Find(0, LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
NextAddress = c.Address
If NextAddress = FirstAddress + 1 Then ' are the
matches continuous?
X = X + 1 'increment the counter
LastRow = NextAddress - 4 'save the row location
Set c = .FindNext(c)
End If
Loop While Not c Is Nothing And X < 4
End If
End With
Range("E1:" & "O" & LastRow).Select
Selection.PrintOut Copies:=1, Collate:=True
End Sub
Thanks
I need to find 4 cells in the same column that have the same value, 4. I
need to save the row so I can use it as the end of my print range.
Here is what I have so far but it's not working. Can anyone help?
Sub PrintDoc()
Dim LastRow As Integer 'Last Row of Printing Range
Dim FirstAddress As Range 'First found occurance of a match
Dim NextAddress As Range ' Next occurance of a match
Dim X As Integer 'counter
X = 0 'set counter to 0
With ActiveSheet.Range("E36:E336")
Set c = .Find(0, LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
NextAddress = c.Address
If NextAddress = FirstAddress + 1 Then ' are the
matches continuous?
X = X + 1 'increment the counter
LastRow = NextAddress - 4 'save the row location
Set c = .FindNext(c)
End If
Loop While Not c Is Nothing And X < 4
End If
End With
Range("E1:" & "O" & LastRow).Select
Selection.PrintOut Copies:=1, Collate:=True
End Sub
Thanks