Switching Between Workbooks.

  • Thread starter Thread starter SpeeD
  • Start date Start date
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
 
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"
 
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"
 
Back
Top