Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default open copy paste

Hi,
I have a userform in a master file that inputs a list of .xl file names into
a column(K) in a worksheet(Selection Properties), the list could contain any
number of .xl file names( from K2 to column("K").end(xldown)). What I want to
do is to open all these files, copy all information on sheet 1 in these files
and paste all into one worksheet in the current master excel file. I am
having difficulty with the code for opening the possible range of values in
column "K".
Thanks for your time
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default open copy paste

Check out GetOpenFileName in VBE help.

I think you can use the example to use the cell contents as the filenames.
Than just loop through all the cells.

Or you could just use workbook.open or Open.

--
steveB

Remove "AYN" from email to respond
"Aonghus" wrote in message
...
Hi,
I have a userform in a master file that inputs a list of .xl file names
into
a column(K) in a worksheet(Selection Properties), the list could contain
any
number of .xl file names( from K2 to column("K").end(xldown)). What I want
to
do is to open all these files, copy all information on sheet 1 in these
files
and paste all into one worksheet in the current master excel file. I am
having difficulty with the code for opening the possible range of values
in
column "K".
Thanks for your time



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default open copy paste

Thant you for your response Steve
My current macro is:

Sub Process_Str()
Dim rw1 As Long, rw2 As Long
' find first open row in each workbook
rw1 = ThisWorkbook.Sheets("Sheet 3").Cells(Rows.Count,
"A").End_(xlUp).Offset(1, 0).Row
rw2 = ActiveWorkbook.ActiveSheet.Cells(Rows.Count,
"A").End(xlUp).Offset(1,_ 0).Row
Dim fName As String
Dim Wkbk As Workbook
Dim curWks As Worksheet
' transfer opened worksheet to master worksheet
ActiveWorkbookname = "Master file"
ActiveSheetname = "Selection Properties"
Set curWks = ActiveSheet
fName = Worksheets("Selection
Propeties").Range("K2").End(xlDown)............run-time error 9 occurs here
Set Wkbk = Workbook.Open(fName)
ActiveWorkbook.ActiveSheet.Range(Cells(2, 25), Cells(rw2,
25)).Copy
Destination = ThisWorkbook.Sheets("Sheet 3").Cells(rw1, 1)
End Sub

I seem to to be missing something but im not to sure what.




"STEVE BELL" wrote:

Check out GetOpenFileName in VBE help.

I think you can use the example to use the cell contents as the filenames.
Than just loop through all the cells.

Or you could just use workbook.open or Open.

--
steveB

Remove "AYN" from email to respond
"Aonghus" wrote in message
...
Hi,
I have a userform in a master file that inputs a list of .xl file names
into
a column(K) in a worksheet(Selection Properties), the list could contain
any
number of .xl file names( from K2 to column("K").end(xldown)). What I want
to
do is to open all these files, copy all information on sheet 1 in these
files
and paste all into one worksheet in the current master excel file. I am
having difficulty with the code for opening the possible range of values
in
column "K".
Thanks for your time




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default open copy paste

Not too sure, but -

this line does look suspecious - make sure it is a single line
fName = Worksheets("Selection
Propeties").Range("K2").End(xlDown)............run-time error 9 occurs here

you might want to get the range address and than define fName just to double
check.
fName = Worksheets("Selection
Propeties").Range("K2").End(xlDown).Address
fName = Range(fName).text

(double check my construct, you might need to add the worksheet to the
formula.)

you can also use R1C1 notation
fName=Cells(Worksheets("Selection
Propeties").Range("K2").End(xlDown).Row,11)

In general R1C1 looks like
Worksheets("Sheet1").Cells(x,y)

hope this helps...
--
steveB

Remove "AYN" from email to respond
"Aonghus" wrote in message
...
Thant you for your response Steve
My current macro is:

Sub Process_Str()
Dim rw1 As Long, rw2 As Long
' find first open row in each workbook
rw1 = ThisWorkbook.Sheets("Sheet 3").Cells(Rows.Count,
"A").End_(xlUp).Offset(1, 0).Row
rw2 = ActiveWorkbook.ActiveSheet.Cells(Rows.Count,
"A").End(xlUp).Offset(1,_ 0).Row
Dim fName As String
Dim Wkbk As Workbook
Dim curWks As Worksheet
' transfer opened worksheet to master worksheet
ActiveWorkbookname = "Master file"
ActiveSheetname = "Selection Properties"
Set curWks = ActiveSheet
fName = Worksheets("Selection
Propeties").Range("K2").End(xlDown)............run-time error 9 occurs
here
Set Wkbk = Workbook.Open(fName)
ActiveWorkbook.ActiveSheet.Range(Cells(2, 25), Cells(rw2,
25)).Copy
Destination = ThisWorkbook.Sheets("Sheet 3").Cells(rw1, 1)
End Sub

I seem to to be missing something but im not to sure what.




"STEVE BELL" wrote:

Check out GetOpenFileName in VBE help.

I think you can use the example to use the cell contents as the
filenames.
Than just loop through all the cells.

Or you could just use workbook.open or Open.

--
steveB

Remove "AYN" from email to respond
"Aonghus" wrote in message
...
Hi,
I have a userform in a master file that inputs a list of .xl file names
into
a column(K) in a worksheet(Selection Properties), the list could
contain
any
number of .xl file names( from K2 to column("K").end(xldown)). What I
want
to
do is to open all these files, copy all information on sheet 1 in these
files
and paste all into one worksheet in the current master excel file. I am
having difficulty with the code for opening the possible range of
values
in
column "K".
Thanks for your time






Reply
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
Open WB, copy each sh. & paste into other WB, regardless of tab na Driftwood Excel Discussion (Misc queries) 0 January 29th 10 02:06 PM
copy paste to first first open row JSnow Excel Worksheet Functions 2 March 6th 09 02:35 PM
Open file, copy field and paste into an Excel doc! - Pl help .. Harish Mohanbab Excel Programming 2 August 4th 05 04:24 PM
Open file, Copy a column and paste this into a new Excel doc - Pl Harish Mohanbabu[_2_] Excel Programming 1 August 4th 05 01:58 PM
open, copy, and paste jacksonz[_5_] Excel Programming 1 July 21st 05 03:23 PM


All times are GMT +1. The time now is 06:29 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"