If statment error

rspalding

Active Member
Joined
Sep 4, 2009
Messages
282
Office Version
  1. 365
Platform
  1. Windows
I'm trying to add the "IF" statements to change my active sheet range. When doing this I get an error.

Set rng = Nothing

rng = if ActiveSheet.Range("P97").Value = "0" Then
With ActiveSheet.PageSetup
ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$73"
End With
End If
If ActiveSheet.Range("P97").Value > "0" Then
With ActiveSheet.PageSetup
ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$99"
End With
End If
If ActiveSheet.Range("P123").Value > "0" Then
With ActiveSheet.PageSetup
ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$125"
End With
End If
If ActiveSheet.Range("P149").Value > "0" Then
With ActiveSheet.PageSetup
ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$151"
End With
End If
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
YES I get an error. I think it is because of the "set rng = ". The origional program just had the following:

Set rng = ActiveSheet.Range("A1:AF73") and this is where I vant to insert the variable based on the data.
 
Upvote 0
MY ERROR.... It does work. I added the code to set the printer page preferences and all is working well.

THANK YOU for your help.
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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