I'm having a problem running a macro from a command button in Excel. I have this procedure that I want to run from the click of a button. The procedure runs great if I run it from the VB window or the immeadiate window. When I try to run it by clicking on a command button, I get the run time error 1004: Method 'Goto' of object _Application' failed.
Here is a sample of the code:
Sub PrintAlpha()
Dim str As String
Dim i As Integer
i = 0
Do
str = Range("PrintCommissions!F6").Offset(i, 0)
Application.Goto Reference:=str
Selection.PrintOut Copies:=1, Collate:=True
i = i + 1
Loop Until Range("PrintCommissions!F6").Offset(i, 0) = ""
End Sub
The error is happening on the following line:
Application.Goto Reference:=str
This code is trying to print a list of range names that are defined in the excel workbook.
Thanks
Dan
Here is a sample of the code:
Sub PrintAlpha()
Dim str As String
Dim i As Integer
i = 0
Do
str = Range("PrintCommissions!F6").Offset(i, 0)
Application.Goto Reference:=str
Selection.PrintOut Copies:=1, Collate:=True
i = i + 1
Loop Until Range("PrintCommissions!F6").Offset(i, 0) = ""
End Sub
The error is happening on the following line:
Application.Goto Reference:=str
This code is trying to print a list of range names that are defined in the excel workbook.
Thanks
Dan