VBA Pagesetup help

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
625
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
ActiveSheet.PageSetup.PrintArea = "$B$13:$V$56,$B$59" & Cells(98, Cells(100, 1).Value)

I have the above code that needs to be modified. The second page column value will change from time to time. So i have the Value in "A100" to give me the column number in this case its "BE" so value "A100=57
the row will always be 98. so I need the above code to read:
VBA Code:
"$B$13:$V$56,$B$59:BE57"
. I could just simply put that in the code however it will not always be till column "BE"

any help is greatly appreciated.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hello Hajiali,
try in this way...
VBA Code:
Sub PageSetUp()
   
    Dim vColumn As String

    vColumn = Cells(98, Cells(100, 1)).Address
    vColumn = Split(vColumn, "$")(1)
    ActiveSheet.PageSetUp.PrintArea = _
        "$B$13:$V$56," & "$B$59:" & vColumn & Cells(100, 1).Value

End Sub
 
Upvote 0
Solution
Thank you EXCEL MAX. I had to remove the

VBA Code:
vColumn = Split(vColumn, "$")(1)
because the vcolumn was the column and row value that I need did not need to spilt it. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top