Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i got it! it works just fine. the main thing i left out was the ...Address
suffix. thank you, mike allen "Incidental" wrote in message oups.com... Hi Mike Sorry if this post appears twice i sent it through already but it hasn't appeared. You could try something like the code below that finds the last used column and row referencing from the cell A1 then sets the print area using this info. Option Explicit Dim VaryingRows As Integer Dim VaryingColumns As String Dim MyLen As Long Private Sub CommandButton1_Click() VaryingRows = [A1].End(xlDown).Row 'Find last used row in Column A VaryingColumns = [A1].End(xlToRight).Address 'Find last used column in Row 1 MyLen = Len(VaryingColumns) 'Check if column is single letter or double If MyLen = 5 Then VaryingColumns = Mid(VaryingColumns, 2, 2) 'Take the column letter from the string Else VaryingColumns = Mid(VaryingColumns, 2, 1) End If 'Set your print area Sheets("Sheet1").PageSetup.PrintArea = "A1:" & VaryingColumns & VaryingRows End Sub I hope this is of some help to you. S |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting print range with macro | Excel Programming | |||
Setting print range using VBA | Excel Programming | |||
Setting print range using VBA | Excel Programming | |||
Setting print range using VBA | Excel Programming | |||
Setting Print range | Excel Programming |