[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Select .CSV file

Posted on 2011-03-14
4
Medium Priority
?
248 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

656 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