The following function should set the print area as a function of column number:
---------------------------------------------
Function setprintarea(ByVal column As Integer) As String
' Sets the print area to range "A1:colstring"
Dim colstring As String
colstring = Chr((column Mod 26 + 65)) & "$35" 'last or only char and row number
If Int(column / 26) >= 1 Then colstring = Chr((Int(column / 26) + 64)) & colstring 'higher order
colstring = "$A$1:" & "$" & colstring
setprintarea = colstring 'returns range
Activesheet.PageSetup.printarea = colstring
End Function
---------------------------------------------
The column number is converted to a string and returned for info purposes. The next line should set the print area. This works when used within a sub program locally within VBA, but not from within the function or in the sub from the worksheet. Is there a restriction on these procedures from within functions? The sub name was not found when entered into a cell, thus the function attempt.
---------------------------------------------
Function setprintarea(ByVal column As Integer) As String
' Sets the print area to range "A1:colstring"
Dim colstring As String
colstring = Chr((column Mod 26 + 65)) & "$35" 'last or only char and row number
If Int(column / 26) >= 1 Then colstring = Chr((Int(column / 26) + 64)) & colstring 'higher order
colstring = "$A$1:" & "$" & colstring
setprintarea = colstring 'returns range
Activesheet.PageSetup.printarea = colstring
End Function
---------------------------------------------
The column number is converted to a string and returned for info purposes. The next line should set the print area. This works when used within a sub program locally within VBA, but not from within the function or in the sub from the worksheet. Is there a restriction on these procedures from within functions? The sub name was not found when entered into a cell, thus the function attempt.