+ Reply to Thread
Results 1 to 4 of 4

Need a macro to import and format data.

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Need a macro to import and format data.

    Hello, I am having an issue with some data that is pulled from an access database. In column A of the attached file, the numbers are stored as text which is throwing off my vlookup formulas. I need a macro that will do two things. First I need to convert all of column A to numbers from text. The issues is that the number of cells in column A is dynamic from one month to the next. The second task I need the macro to do is remove any text characters after the four digit number.

    Because I was asked to put this together for someone who is very challenged with excel, I need this to be done by having the end user push a button on the sheet, having a dialog box open for the user to be able to select the sheet with the data and have it import the data into this sheet.

    I have no idea how to do this myself, but I am trying to learn so any help would be appreciated.

    Thanks!
    Clayton Grove
    Attached Files Attached Files

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Need a macro to import and format data.

    See attached sheet.

    This satisfies your first two criteria.

    as per
    having a dialog box open for the user to be able to select the sheet with the data and have it import the data into this sheet
    I'm not too sure what exactly you mean.
    Are there multiple sheets which may be referenced from, and you want this box to allow them to choose which one?

    Also -
    VLOOKUP requires the data in the first column to be sorted in ascending order. That will cause you problems with these numbers as they are currently not sorted.
    Attached Files Attached Files
    Last edited by mewingkitty; 01-30-2009 at 05:12 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need a macro to import and format data.

    Hello Clayton,

    To check you data after it has been downloaded from a database, you can use the worksheet function CELL to return information about the format and data type of the cells. In this case, the test shows your data is a number formatted as follows "#,##0.00". How did you determine it was text?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need a macro to import and format data.

    Hello Clayton,

    I added this macro to your workbook. This reformats all the cells as numbers using the format "#,##0.00"
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

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