Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assume column C can be used to determine the extent of printing (the last
line to be printed will contain a value in column C). Sub ABC() Dim rng as Range, rng1 as Range, rng2 as Range Dim i as Long set rng = Cells(rows.count,3).End(xlup).offset(1,-1) rng.Value = "End" set rng1 = Range("B10",rng).SpecialCells(xlConstants) for i = 1 to rng1.areas.count - 1 set rng2 = range(rng1(i),rng1(i+1)(0)) rng2.Resize(,16).Printout Next rng.ClearContents End Sub Assumes there will be blank cells in each range to be printed and that the start (top left Cell) of the print area contains a constant (not a formula and not blank). -- Regards, Tom Ogilvy "Graham Haughs" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Procedure name as variable | Excel Programming | |||
Variable procedure call | Excel Programming | |||
Call procedure using variable | Excel Programming | |||
Public/Procedure Variable | Excel Programming | |||
can I call a procedure using a variable | Excel Programming |