To be more specific: I want to have the position of my last column and row in a certain pivot table. When there are more columns than rows...than I need a xlLandscape pagesetup, else I need a slPortrait pagesetup.
I can do this:
Select the range of the generated pivot...
Application.ScreenUpdating = False
Dim myLastRow As Long
Dim myLastColumn As Long
Range("A1").Select
myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
myLastCell = Cells(myLastRow, myLastColumn).Address
myrange = "a1:" & myLastCell
Application.ScreenUpdating = True
Range(myrange).Select
then I can do this:
I determine the number of columns....(and rows, but dont need those)
Dim iColumnCount As Integer
Dim lRowCount As Long
iColumnCount = ActiveSheet.UsedRange.Columns.Count
lRowCount = ActiveSheet.UsedRange.Rows.Count
At this moment I know this: Number of columns = 14. and rows are 12
Good!
But then my code fails. I'm not able to do:
If ColumnCount < lRowCount then
ActiveSheet.PageSetup.Orientation = xlLandscape
Else: ....etc...
Can somebody help me out? pls?
Bookmarks