VBA call a macro during a active x button

jaxisdex

New Member
Joined
May 26, 2015
Messages
35
I have a command button macro that is set up. in it i call a Sub from the workbook. When i run the macro by itself, it works just fine. The command button works just fine by itself as well, but once they are combined it ends up giving me an error. "Run-time error '9': Subscript out of range" the thing that really confuses me is, this will go away sometimes if i restart excel or it will go away if i restart my entire computer. now as you may guess, im not fond of this time waste and would like any help or advice on why this may be happening!

The command button

Sheets(Array("Sales Snapshot", "Agent Rejections", _
"Agent Estimate Lost Profit", "CPS Links")).Copy

Call saveUniversal <--- the macro that gets called

ActiveSheet.PivotTables("PivotTable5").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ etc etc etc


The save macro
Sub saveUniversal() <--- the macro that is getting called
Dim FName As String
Dim FPath As String


Dim wbBook1 As Workbook


Set wbBook1 = ActiveWorkbook


FPath = "T:\Client Services\Cancellation Wheels\Weekly Data\Quill\"
FName = wbBook1.Sheets("CPS Links").Range("A4").Text <--- this is where the iusse is. it sometimes works fine sometimes it doesnt.
wbBook1.SaveAs Filename:=FPath & "\" & FName


End Sub


thank you for your help,
Jaxs
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,727
Messages
6,126,512
Members
449,316
Latest member
sravya

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