G
Graham Haughs
I use the procedure below to look for change of values in Column B then
at that change print out a range as shown. This works fine but it is not
ideal. The values down column B ideally should be one value followed by
some variable blanks before a new value appears in Column B and then I
would want to print out the range up to that point but not including the
new value. This would in turn be followed by some blanks before a new
value again appears and so on. The point that printing would need to
stop would be another challenge as the last value would appear and of
course it would be all blanks after that. It would be allowable to print
that one with up to four rows below it before stopping the procedure. It
is not possible to just print each value plus say five blanks as the
number of blanks after each value is variable. This may not be feasible
but I would value any guidance. Sorry if this is not explained very well.
Dim cell As Range
Dim l count As Long
Dim rCol As Range
'Get the last cell in column A
With Sheets("Field Records")
Set rCol = .Range("B10", .Range("B" & .Rows.Count).End(xlUp))
End With
'Loop through column B
For Each cell In rCol.Cells
'If a new value
If cell.Value <> cell.Offset(-1, 0).Value Then
'Count the number of similar values in col B
lCount = Application.CountIf(rCol, cell.Value)
'Resize a range and print it out
cell.Resize(lCount, 16).PrintOut
End If
Next cell
Kind regards
Graham Haughs
Turriff, Scotland
at that change print out a range as shown. This works fine but it is not
ideal. The values down column B ideally should be one value followed by
some variable blanks before a new value appears in Column B and then I
would want to print out the range up to that point but not including the
new value. This would in turn be followed by some blanks before a new
value again appears and so on. The point that printing would need to
stop would be another challenge as the last value would appear and of
course it would be all blanks after that. It would be allowable to print
that one with up to four rows below it before stopping the procedure. It
is not possible to just print each value plus say five blanks as the
number of blanks after each value is variable. This may not be feasible
but I would value any guidance. Sorry if this is not explained very well.
Dim cell As Range
Dim l count As Long
Dim rCol As Range
'Get the last cell in column A
With Sheets("Field Records")
Set rCol = .Range("B10", .Range("B" & .Rows.Count).End(xlUp))
End With
'Loop through column B
For Each cell In rCol.Cells
'If a new value
If cell.Value <> cell.Offset(-1, 0).Value Then
'Count the number of similar values in col B
lCount = Application.CountIf(rCol, cell.Value)
'Resize a range and print it out
cell.Resize(lCount, 16).PrintOut
End If
Next cell
Kind regards
Graham Haughs
Turriff, Scotland