Workbook.sheets.range.select problems

RET79

Well-known Member
Joined
Mar 19, 2002
Messages
526
HI.

Can anyone suggest why I am having so much difficulty going back and forth between two sheets from a different workbook when writing a macro? It keeps on saying subscript out of range, object doesnt support this proeprty etc.

All I need to do is copy something from workbook B, delete the contents on sheet2 on workbook A and paste the copied code on sheet2.

It seems like such a straightfoward thing to do but for some reason nothing seems to work and it is very frustrating.

Have I got some setting I need to change?

Thanks,

RET79
 
do you know how to debug your code , sometimes watching what is going on in debug mode will answer your question , I have a lot of trial and error stuff Debuging makes it.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
OK, I have another problem for u with this thing.

The 'original' workbook I do not know the name of as I am using this:

filetoOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")

thing. This gives me the full path of the file, so won't work like this:

Workbooks(filetoOpen). ....
does not work.

Is there a way of reducing the file path to just get the filename.xls out and then use that in the Workbooka("filename.xls").activate format?

Thanks

RET79
 
Upvote 0
Sorry, I am answering my own question.

For that new text file I can just use

namesheet = activesheet.name & ".txt"

then can say
Workbooks(namesheet).activate

further on.
 
Upvote 0

Forum statistics

Threads
1,214,534
Messages
6,120,080
Members
448,943
Latest member
sharmarick

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