Solved

Select .CSV file

Posted on 2011-03-14
4
243 Views
Last Modified: 2012-05-11
Hi,

Im looking to copy over some data from one file to another, i cant use workbook.activate("XYZ.xls") because the file name changes each day, i donr want to use activate next workbook as the user may have multiple workbooks open.

Can i select the workbook to paste into based the on the fact it finishes .CSV as opposed to .xls

So something like

select.'code'
Copy entire workbook
Select "xyz.xls"
Paste into sheet "abc"

Select CSV file
Close
Dont save changes

Thanks!
Seamus
0
Comment
Question by:Seamus2626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 35130048
Hi Seamus, you can use code like this to get your csv workbook

Dim wbk As Workbook, wbkCSV As Workbook

For Each wbk In Application.Workbooks
    If UCase(Right(wbk.Name, 4)) = ".CSV" Then
        Set wbkCSV = wbk
        GoTo foundCSV
    End If
Next

MsgBox "CSV not found"
Exit Sub
foundCSV:

'continue your paste and close

Open in new window


Thomas
0
 

Author Closing Comment

by:Seamus2626
ID: 35130392
Thanks Thomas!
0
 
LVL 39

Expert Comment

by:nutsch
ID: 35130494
Glad to help. One warning: this will take the first csv workbook found, which could be an issue if you have more than one open.

T
0
 

Author Comment

by:Seamus2626
ID: 35130604
Thats fine, will only ever have one.

Cheers,
Seamus
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question