workBook Activate doesn't work...

  • Thread starter Thread starter Buffyslay
  • Start date Start date
B

Buffyslay

hi there

i am trying to copy data from various workbooks in excel -(open ones) i
dont know the names, but i do know the sheet is called sheet1 (i
know....)

i need the data to be put into wbMaster (main doc already referenced) -
but when it gets to

Windows(wbMaster).Activate
Workbooks(wbMaster).Worksheets("Return").Activate
(trying both)


it doesn't activate the wbMaster doc.... ??






code below*
*****************************************************************************************************
If wkb.Name <> wbMaster Then
If Windows(wkb.Name).Visible Then

wkb.Activate
For Each ws In wkb

If ws.Name = "Sheet1" Then
' copy all the data into the COMPARE wb
Worksheets("Sheet1").Activate
lRowCount = ActiveSheet.UsedRange.Rows.Count - 1
iColCount = ActiveSheet.UsedRange.Columns.Count
Range("A2", Range("A2").Offset(lRowCount,
iColCount)).Select
Selection.Copy
Windows(wbMaster).Activate

Workbooks(wbMaster).Worksheets("Return").Activate


MsgBox ActiveWorkbook.Name


lRowCountReturnTemp = ActiveSheet.UsedRange.Rows.Count
- 1
Range("A2").Offset(lRowCountReturnTemp, 0).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
End If
Next


End If
'ListBox1.AddItem wkb.Name
End If
 
ok - sussed it - wbMaster was old name - so changed the name to
wbMaster = Application.ActiveWorkbook.Name

works now
 

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

Back
Top