Hi,
I still hope to get some help with retrieving data from a particular sheet from a particular workbook.
To make it clear... The workbook name is located in on sheet "Name 1" and in Cell "B2".
The name of the needed sheet will be located on the same sheet in cell "B3".
I need to apply this to 28 different names/workbooks weekly. But I have no clue how to do it. I tried to work with the next macro coding. It does what I need, but I don't know how to apply the information located in cell B2 and B3. I twould even be great if I could loop this for the whole folder "CC" or something, but that is not really important right now.
I am getting lost..
This is the macro/VBA coding:
[pre]
[/pre]
In the next part:
Const SheetName$ = "Week 21"
I would like to refer to a cell on the main sheet where I would fill in the data manually
I might could do the same for:
Const FileName$ = "Name 1.xls"
But then would like to refer to a list of names or something.
Please help me out. I am just a beginner in Macro's.
I still hope to get some help with retrieving data from a particular sheet from a particular workbook.
To make it clear... The workbook name is located in on sheet "Name 1" and in Cell "B2".
The name of the needed sheet will be located on the same sheet in cell "B3".
I need to apply this to 28 different names/workbooks weekly. But I have no clue how to do it. I tried to work with the next macro coding. It does what I need, but I don't know how to apply the information located in cell B2 and B3. I twould even be great if I could loop this for the whole folder "CC" or something, but that is not really important right now.
I am getting lost..
This is the macro/VBA coding:
[pre]
Code:
Option Explicit
'credit for this technique goes to John Walkenback
'http://j-walk.com/ss/excel/tips/tip82.htm
Sub GetDataDemo()
Dim FilePath$, Row&, Column&, Address$
'change constants & FilePath below to suit
'***************************************
Const FileName$ = "Name 1.xls"
Const SheetName$ = "Week 21"
Const NumRows& = 30
Const NumColumns& = 17
FilePath = ActiveWorkbook.Path & "CC"
'***************************************
DoEvents
Application.ScreenUpdating = False
If Dir(FilePath & FileName) = Empty Then
MsgBox "The file " & FileName & " was not found", , "File Doesn't Exist"
Exit Sub
End If
For Row = 9 To NumRows
For Column = 5 To NumColumns
Address = Cells(Row, Column).Address
Cells(Row, Column) = GetData(FilePath, FileName, SheetName, Address)
Next Column
Next Row
ActiveWindow.DisplayZeros = False
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data$
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function
In the next part:
Const SheetName$ = "Week 21"
I would like to refer to a cell on the main sheet where I would fill in the data manually
I might could do the same for:
Const FileName$ = "Name 1.xls"
But then would like to refer to a list of names or something.
Please help me out. I am just a beginner in Macro's.