Results 1 to 3 of 3

Macro to concatenate variable amount of columns

Threaded View

phil3061 Macro to concatenate variable... 04-15-2013, 01:05 PM
stnkynts Re: Macro to concatenate... 04-15-2013, 02:07 PM
phil3061 Re: Macro to concatenate... 04-15-2013, 02:53 PM
  1. #1
    Registered User
    Join Date
    10-12-2011
    Location
    New Castle, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Macro to concatenate variable amount of columns

    Hello,

    I'm really hoping someone can help me out with this. I get requests in all the time that are Excel workbooks, that I have to then convert into SQL tables. The problem is, none of the formats of these Excel files are the same, so I spend a lot of time cleaning them up, then almost as much time using Visual Studio to import the data into SQL Server.

    It will save me a lot of time, if I can bypass VS, and just create the table through code. But I need to have all the columns concatenated to do that. Is there a way look in row 1 for the first non-blank cell. Once found, in this case cell I1, then starting in I2 inserting a formula to put a single quote around each value in each cell, and comma between each cell. The tricky part is that because there are no standard formats, sometimes these requests can come in with 3 columns of data or 50 columns, and 10 rows of data or 500,000. So it needs to be able to loop through the data to always find the last column to start the formula, and the last row to end. Also, if the cell is blank, for proper import into the table, it would need to output '', not just skip over it.

    Oh, and almost forgot, the date column when concatenated comes in integer form, I need to keep it in Date formate.

    Any help would be greatly appreciated.

    Thanks.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1