Switching Between Workbooks.

S

SpeeD

Hi.

I need to switch between worobooks, but i never know the name of one of them.

Dim Nome As Workbook
Set Nome = ActiveWorkbook.FullName

Range("A2").Select
Selection.CurrentRegion.Select
Selection.Copy
Windows("ordenação para folha final.xls").Activate
Sheets("Original 1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Windows("Nome").Activate
Range("A1").Select

Can anyone help me with this? i can ´t get this to work...
one more thing the code is in another book that is open...

Thansk a lot!!!!!!!!!!!!
SpeeD
 
J

Jim Thomlinson

The best way is to get familiar with workbook objects.

dim wbk1 as workbook
dim wbk2 as workbook

set wbk1 = activeworkbook
set wbk2 = workbooks("MyBook.xls")

'the book where the code is running can always be refered to as ThisWorkbook

wbk1.activate
msgbox "You are here'
wbk2.activate
msgbox "Now here"
thisworkbook.activate
msgbox "and back to here"
 
S

SpeeD

Thanks a lot Jim!

It works great!

SpeeD



Jim Thomlinson said:
The best way is to get familiar with workbook objects.

dim wbk1 as workbook
dim wbk2 as workbook

set wbk1 = activeworkbook
set wbk2 = workbooks("MyBook.xls")

'the book where the code is running can always be refered to as ThisWorkbook

wbk1.activate
msgbox "You are here'
wbk2.activate
msgbox "Now here"
thisworkbook.activate
msgbox "and back to here"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top