×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Find worksheet and import data?

Find worksheet and import data?

Find worksheet and import data?

(OP)
Hi folks

I need help on loading data from many different workbooks into a different workbook/worksheet so I can analyse the data. All Excel files have the same path, but some workbooks have the specific worksheet others not. The specific worksheets have the same name and the cell range is the same.

E.g.: look for worksheet "W1" on different workbooks; if available, copy the cell range and past on column A, B, C.... (for each data set) on worksheet "summary" of workbook "Data". Row 1 needs to have the workbook name for identification.

Likely this solution is available in this forum, so send me the links so I can start.

Thx

RE: Find worksheet and import data?

If the solution is ready made then use of the Search facility may find it. I didn't see a ready made answer so I've knocked up a quick solution for opening the workbooks. Getting the data from each should then be fairly trivial by simply recording a macro, and substituting to reference in your code.

CODE

Private Sub CommandButton1_Click()
Dim curbook As String
Dim myERR As Integer
Dim strFile As String
Dim Counter As Integer
On Error GoTo myERR
curbook = Workbooks(1).Name
Counter = 0
strFile = Dir("F:\My Documents\Worksheets\*.xls")
Do While Len(strFile) > 0
Counter = Counter + 1
If strFile <> curbook Then
    Workbooks.Open Filename:=strFile
    Sheets("w1").Select
End If
strFile = Dir
Loop
Exit Sub
myERR:
If Err.Number = 9 Then
Workbooks(Counter).Close
Resume Next
End If
End Sub

You will need to change strFile = Dir("F:\My Documents\Worksheets\*.xls") to point to your own directory of course

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

RE: Find worksheet and import data?

(OP)
thanks for the input. I'll try it later and let you know. rgds

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources