Hi
I need to select ranges in an open but non-active workbook without activating it
Any idea how i can go about it??
Aadarsh
Hi
I need to select ranges in an open but non-active workbook without activating it
Any idea how i can go about it??
Aadarsh
Re: selecting ranges in non-active workbooks
hi
I tried the method u told me...I get a subscript not found error on the 'SET' line
Aadarsh
Re: selecting ranges in non-active workbooks
aadarsh,
Sub WS_range()
Dim wkbOther as workbook
Dim wksOther as worksheet
set wkbOther = Workbooks("PutWorkbookNameHere")
set wksOther = wkbOther.Worksheets("SheetNameHere")
Range("A1") = wksOther.Range("A1") 'Copies from other sheet to activesheet...
End Sub
Display More
Make sure you change the value "PutWorkbookNameHere" to the appropriate workbook name.
Make sure you change the value "SheetNameHere" to the appropriate worksheet name.
Re: selecting ranges in non-active workbooks
Hi
Thanx for the instant reply...
I tried your method..I still get the subscript out of range..
I have opened the same file before for printing but then dosent give me an error..
But only in this instance it does
Aadarsh
Re: selecting ranges in non-active workbooks
Which line gets the error.
Sometimes the name of a workbook ( depending on xl settings ) having the .xls portion of the workbook causes errors.
The only reason that I can think of for getting errors are these.
1. Workbook is not open.
2. Name is not correct
3. Worksheet is not correct.
There is another reason for this especially if you've got the name correct and the book is open.
Re: selecting ranges in non-active workbooks
The error is on the Set line for the workbook
The workbbok is open cos i am also printing stuff into it..and the name is correct
Re: selecting ranges in non-active workbooks
Program.xls
This is the file from which i Am running my commands...
The output file is called output.xls...thats where i need to select range
Aadarsh
Re: selecting ranges in non-active workbooks
So are you saying that when the loop runs the only message box that pops up is for the current workbook??
If so that means the other workbook has opened another instance of XL ( which is different than another workbook in the same instance ). How is the other workbook opened?
Re: selecting ranges in non-active workbooks
To help explain this let me try to explain.
When you click ( let's say on a short cut ) for an XL workbook. If you haven't specified the program to use it uses the program that is associated with that file. It opens without issue.
Now let's say that when you make a short cut to an xl file you actually short cut to the xl.exe file and on the command line add the path to the file. What happens then is that a new instance of xl opens regardless if a workbook is all ready open. A consequence of this is that neither book can talk to each other. Another consequence if you try to copy / paste between the two instances it doesn't work very well.
Re: selecting ranges in non-active workbooks
hi barry
Thanx for the help...solved the problem...the excel file was opened for print as a txt file..hence all the confusion
Solved it now
aadarsh
Don’t have an account yet? Register yourself now and be a part of our community!