Set a name range that works when calling other macros

gordonlyle

New Member
Joined
Mar 6, 2017
Messages
9
Hi clever folks,

Is there a way to name a range that will work when calling other macros?

By this I mean that in the example below, if I run "rail4_megacalc" then it errors when it finds 'cantilever' as it doesn't seem to have a name associated. I'm just trying to reduce the amount of times I have to recreate the span1200 when I have many


Sub rail4_megacalc()

' calculates rail 4 with all fixed point brackets
'
Dim cantilever As Range
Set cantilever = Range("AH17:AJ17")
Dim span As Range
Set span = Range("AH21:AJ21")
Dim check As Range
Set check = Range("AD37")
Dim fixed As Range
Set fixed = Range("AB27:AD27")

Call span1200


End Sub


Sub span1200()

cantilever.Select
ActiveCell.FormulaR1C1 = "600"
span.Select
ActiveCell.FormulaR1C1 = "1200"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "550"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "500"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "450"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "400"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "350"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "300"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "250"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "200"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"
cantilever.Select
ActiveCell.FormulaR1C1 = "150"
If check = "0" Then End
fixed.Select
ActiveCell.FormulaR1C1 = "Fixed double"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed XL"
If check = "0" Then End
ActiveCell.FormulaR1C1 = "Fixed single"

End Sub


Many thanks to you all in advance. :)
Gordon

 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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