Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
copy cell from file with variable name
I need to copy a cell value from file having name d:\....\file001.xls into
currently open worksheet in cell E1. The value "001" is a sequence number existing in current worksheet in cell C1. The requirement is to copy one cell from file001.xls into E1, file002.xls into E2 ... and so on. Corresponding numbers exist in C1, C2 .... etc. i.e. if C10 is "015", then E10 will receive value from file015.xls. Number in column C are in ascending order. Is this possible? |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
copy cell from file with variable name
Hi,
Right click the sheet tab where you are going to copy the data to, view code and paste this in and run it. Sub sonic() Dim Lastrow As Long Dim Folder As String, CopyValue As String Lastrow = Cells(Rows.Count, "C").End(xlUp).Row Folder = "C:\" 'Change to your path For Each c In Range("C2:C" & Lastrow) Workbooks.Open Filename:=Folder & "File" & c.Value & ".xls" CopyValue = Sheets("Sheet1").Range("A1").Value ActiveWorkbook.Close False c.Offset(, 2).Value = CopyValue Next End Sub Mike "hsg" wrote: I need to copy a cell value from file having name d:\....\file001.xls into currently open worksheet in cell E1. The value "001" is a sequence number existing in current worksheet in cell C1. The requirement is to copy one cell from file001.xls into E1, file002.xls into E2 ... and so on. Corresponding numbers exist in C1, C2 .... etc. i.e. if C10 is "015", then E10 will receive value from file015.xls. Number in column C are in ascending order. Is this possible? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How a cell can be addressed with variable file-column? | Excel Discussion (Misc queries) | |||
how to copy a cell in excell and paste in a txt file with macro | Excel Discussion (Misc queries) | |||
Variable in VLOOKUP and referencing a cell another file in excel | Excel Worksheet Functions | |||
COPY CELL WITH FILE REFERENCES IN EXCEL | Excel Discussion (Misc queries) | |||
How do I copy data from a cell in one file to another? | New Users to Excel |