Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Area Property - Cannot set dynamically

Status
Not open for further replies.

thestampdad

Technical User
Nov 2, 2001
14
Hope someone can help me with this.

I am trying to set a print area that is 14 columns wide but can be any number of rows. The number of rows changes daily.

The print area cannot be "hard coded" it must be dynamic.

Here is my code so far:

sub printing()
ActiveSheet.PageSetup.PrintArea = ""

Range("A1").Select
Range("A12").Select
ActiveCell.Offset(0, 0).Activate
Set Top = ActiveCell.Offset(0, 0)

ActiveCell.SpecialCells(xlLastCell).Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlUp).Select

ActiveCell.Offset(0, 13).Activate
Set bottom = ActiveCell.Offset(0, 0)

Range(Top, bottom).Select

ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

End Sub()

The last statement above "ActiveCell.CurrentRegion.Address" does not work because not all of the columns have data so this statement only finds cells with data.

What st
 
Set Range equal to first three columns in Worksheets("Main").

Sub PrintRangeInfo(rngCurrent As Excel.Range)
Dim rngTemp As Excel.Range
Dim strValue As String
Dim strRangeName As String
Dim strAddress As String
Dim strFormula As String

On Error Resume Next

strRangeName = rngCurrent.Name.Name _
& " (" & rngCurrent.Name.RefersTo & ")"
strAddress = rngCurrent.Address

For Each rngTemp In rngCurrent.Cells
If IsEmpty(rngTemp) Then
strValue = strValue & "Cell(" & rngTemp.Address _
& ") Is empty." & vbCrLf
Else
strValue = strValue & "Cell(" & rngTemp.Address _
& ") = " & rngTemp.Value _
& " Formula " & rngTemp.Formula & vbCrLf
End If
Next rngTemp
Debug.Print IIf(Len(strRangeName) > 0, "Range Name = " _
& strRangeName, "Range not named") & vbCrLf & "Address = " _
& strAddress & vbCrLf & strValue
Debug.Print "**********************************"
Debug.Print
If Err > 0 Then Err = 0
End Sub Best Regards

---
JoaoTL
mail@jtl.co.pt
MS Access Site: The Page: moved to
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top