LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Activate an variable located workbook and copy 2 ranges?

Dear experts,

I have a program need 2 ranges of data from a file that need to be located
by user.I need to copy and paste them into thisworkbook.

Here is the code to located and get the directory and filename of the
source(it does not open that file for now):

Private Sub CommandButton5_Click()
Dim Filter, Title As String
Filter = "Excel Files (*.xls),*.xls, CSV Files (*.CSV), *.csv,"
Title = "Select Files to Calculate"
With Application
Fname5 = .GetOpenFilename(Filter, FilerIndex, Title, , ture)
End With
TextBox5.Value = Fname5
End Sub

Now I start to copy the first range to thisworkbook, (lrow1 is a variant
stores the length of the first range): First open source file, copy the
range, then activate thisworkbook, and paste the first range into a loaction.

Dim Workbook5 As Workbook
Set WookBook5 = Workbooks.Open(Fname5)
Worksheets("Sum_Page").Activate
ActiveSheet.Range("A2:A" & lrow1).Copy
ThisWorkbook.Activate
Sheets("Last_Mth").Activate
ActiveSheet.Paste Destination:=Worksheets("Last_Mth").Range("A2:A" & lrow1)

Now I need to activate the source file again to copy the 2nd range, but i
can not do it without closing and reopening it. following code does not
working:

Workbook5.activate
or
workbooks(workbook5).activate
or
workbooks.open (Workbook5)
or
workbooks(Fname5).activate

What is the right code to re-activate it without openning it twice?

Thanks

Will

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Recording a macro to copy into a series of variable ranges peters Excel Programming 3 August 10th 07 10:44 PM
Activate Macro Button Located In Another File Aria[_2_] Excel Programming 2 October 26th 06 02:03 AM
Counting variable ranges and auto-summing variable ranges Father Guido[_5_] Excel Programming 2 March 29th 06 04:07 AM
Copy variable ranges fron difernte shets optimus_1973 Excel Worksheet Functions 2 January 8th 06 04:39 AM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"