Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a workbook open but not active named 123Q and a
Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 23 Nov., 18:04, Oldjay wrote:
I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay Hi Try this: quotenumber=Workbook("123Q").Worksheets("Input").R ange("AB2").Value Regards, Per |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can't use 123Q because the inactive workbook is variable.
" wrote: On 23 Nov., 18:04, Oldjay wrote: I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay Hi Try this: quotenumber=Workbook("123Q").Worksheets("Input").R ange("AB2").Value Regards, Per |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try changing from:
quotenumber = Range("Input!ab2") To: quotenumber = Worksheets("Input").Range("ab2") "Oldjay" wrote: I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub CommandButton2_Click() 'Generates PDF Quote Form
Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Worksheets("Input").Range("ab2") quotenumber1 = quotenumber + "Q" + ".xls" Windows("quotenumber1").Activate Tried it but have the same result "JLGWhiz" wrote: Try changing from: quotenumber = Range("Input!ab2") To: quotenumber = Worksheets("Input").Range("ab2") "Oldjay" wrote: I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Take the quotes off the last line:
Windows(quotenumber1).Activate With that change it works for me in a regular module. But I agree with the other posts that suggest a different way to reference the range, although I don't think that's why you are seeing the error. -- Tim Zych SF, CA "Oldjay" wrote in message ... I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks That did the trick
"Tim Zych" wrote: Take the quotes off the last line: Windows(quotenumber1).Activate With that change it works for me in a regular module. But I agree with the other posts that suggest a different way to reference the range, although I don't think that's why you are seeing the error. -- Tim Zych SF, CA "Oldjay" wrote in message ... I have a workbook open but not active named 123Q and a Range("Input!ab2") = 123 Private Sub CommandButton2_Click() 'Generates PDF Quote Form Dim CurrentPrinter As Variant Dim quotenumber As String Dim quotenumber1 As String quotenumber = Range("Input!ab2") quotenumber1 = quotenumber + "Q" + ".xls" 'Windows("quotenumber1").Activate Why do i get an error message "subscript out of range" oldjay |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Activate Workbook | Excel Programming | |||
Workbook.Activate / Window.Activate problem | Excel Programming | |||
Activate workbook | Excel Programming | |||
Workbook.activate | Excel Discussion (Misc queries) | |||
Activate Workbook | Excel Programming |