LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Automate Text Import for Multiple Files

You can leave the empty column by changing this code:

'get ready for the next one
Set DestCell = DestCell.Offset(0, 1)
to:
'get ready for the next one
Set DestCell = DestCell.Offset(0, 1)
If DestCell.Column Mod 4 = 0 Then
Set DestCell = DestCell.Offset(0, 1)
End If

But since your file names aren't nicely formatted, it would be more difficult to
sort. You could write code that formats the names in a consistent manner so
that:

ADP - 1nM - 1
ADP - 1nM - 2
ADP - 1nM - 3
ADP - 10nM - 1
ADP - 10nM - 2
ADP - 10nM - 3
ADP - 100nM - 1
ADP - 100nM - 2
ADP - 100nM - 3

looks more like:
ADP - 0001nM - 1
ADP - 0001nM - 2
ADP - 0001nM - 3
ADP - 0010nM - 1
ADP - 0010nM - 2
ADP - 0010nM - 3
ADP - 0100nM - 1
ADP - 0100nM - 2
ADP - 0100nM - 3

Then sorting becomes a lot easier. (although your sorting requirement is even
more different.)

But I think I'd try to change the thing that creates those files so that it uses
nicer named files.

wrote:

On Feb 14, 11:27 am, Dave Peterson wrote:
Macros live in workbooks. And to run the macro, the workbook has to be open.

With a procedure like this, I'd create a dedicated workbook with this single
macro. I'd plop a button from the Forms toolbar on the only worksheet in the
workbook. Then I'd assign this macro to the button.

Then whenever I needed this functionality, I'd open this workbook and click that
big old button.

wrote:

<<snipped



Thank you kindly for the help. The code worked great. Now I have
another, very novice question. Where do I put/save this macro so
that, when I'm in Excel, I can run it. Right now it's saved in a
Macro-enabled workbook. Is opening the workbook with the macro in it
the only way to use the macro? Thanks again!


--

Dave Peterson


That sounds like a great idea. I will give that a go later tonight.
I do have some additional questions though. They relate to the style
of the imported spreadsheet. For example, is it possible to import
into adjoining columns as described earlier, but (for example) to
leave an empty column between every three columns containing data?
Also, I was wondering about the order in which the files get
imported. Is there any way to modify this? For example, I have files
named like so:

ADP - 1nM - 1
ADP - 1nM - 2
ADP - 1nM - 3
ADP - 10nM - 1
ADP - 10nM - 2
ADP - 10nM - 3
ADP - 100nM - 1
ADP - 100nM - 2
ADP - 100nM - 3

That's the order I'd like them to be imported, but they are actually
imported in the following order:

ADP - 100nM - 1
ADP - 100nM - 2
ADP - 100nM - 3
ADP - 10nM - 1
ADP - 10nM - 2
ADP - 10nM - 3
ADP - 1nM - 1
ADP - 1nM - 2

I'm unable to sort them based on the name no matter what format those
title cells are in (general, text, number). Any thoughts?

Thanks again for your kind assistance!
ADP - 1nM - 3


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import multiple text files (Macro) Thr33of4 Excel Discussion (Misc queries) 0 September 19th 06 02:19 AM
Import of Multiple Text Files yanks6rule[_2_] Excel Programming 1 January 26th 06 11:34 PM
Need to import multiple files with a macro HatTrick Excel Programming 0 August 5th 04 03:57 PM
Import multiple text files into excel Wally Steadman[_2_] Excel Programming 1 November 15th 03 04:14 PM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"