PDA

View Full Version : Solved: Printing code



tofimoon4
06-09-2013, 03:40 AM
Dear sir,with best regards,asking your goodselves for help by a code to print only the used cells which are here within the range (BG2:BN12).
Many thanks in advance.

p45cal
06-09-2013, 04:49 AM
In the attached there is a button on sheet1 which calls the following code:Sub blah()
lr = TheLastRow(ActiveSheet.Range("BG2:BN32"))
Range("BG2:BN" & lr).PrintPreview
End Sub
Function TheLastRow(rng)
On Error Resume Next
TheLastRow = rng.Find(what:="*", After:=rng.Cells(1), lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
On Error GoTo 0
End Function

tofimoon4
06-09-2013, 05:50 AM
Dear sir,many thanks for help,it works very nice.