+ Reply to Thread
Results 1 to 9 of 9

check each cell in a column and convert to text

  1. #1
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    check each cell in a column and convert to text

    Hi
    I have in column C a list of numbers ranging from 100 to 2000, for all 3 digit numbers i want them to be displayed as 0100 (with a 0 added at the beginning)
    as the format is important for other macros to work well.. Any help is appreciated thanks!

    Also, the macro has to be run over an entire folder,i currently have this code that converts csv files to xls, if you can add to this code to take care of number conversion , that would be great.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: check each cell in a column and convert to text

    Also, in the above code, i get csv to xls conversion but i have both files in my folder, is there a way to delte the original csv files?

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check each cell in a column and convert to text

    To "Format" a column with a 4 digit display is pretty easy, it's the kind of thing you could turn on the macro recorder and record yourself doing that manually, then slip the code snippet you pull from the recorded macro into your other macros(s) as needed.

    The KILL command can be used to delete a file, since you already have the path and filename, you're almost there.

    See if you can work those two things out from these two hints. Post back with what you're tried if what you come up with doesn't work.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: check each cell in a column and convert to text

    i got this:
    Please Login or Register  to view this content.
    and it works :D thanks!!
    but when i proceed to next step of my task copying the cell value to be used somewhere else,again copies the 3 digit number...can w e convert this to text

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check each cell in a column and convert to text

    You said you wanted to FORMAT the column C to display 4 digits, which I'm sure your highlighted code actually does. But it's just a display trick, the value in the cell is still 3 digits.

    You can perform the same "trick" on the fly in your other code to take the value in the cell and "format" it as you use it elsewhere. For instance, using a single sample value in C2:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: check each cell in a column and convert to text

    I tried something like this:
    Please Login or Register  to view this content.
    Still having same issue..can u correct me if somethings wrong

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check each cell in a column and convert to text

    After you have converted the column C itself to text, I'm thinking the code above would work.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: check each cell in a column and convert to text

    Great this works..but once i do this @ conversion , the 0000 formatting is lost in the original sheer

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: check each cell in a column and convert to text

    That is correct. But your macro will be able to do what it needs to do.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Check if a cell contains text copy number to new column
    By lto120636 in forum Excel General
    Replies: 5
    Last Post: 07-14-2014, 08:39 AM
  2. Check cell contains if contains text check another column.
    By thequiff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2013, 07:29 AM
  3. [SOLVED] VBA to convert cell to text and ensuring 7 digit number all along in entire column.
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-19-2013, 09:35 AM
  4. Replies: 2
    Last Post: 05-28-2013, 06:26 AM
  5. Macro to check column A and copy text from cell above
    By robertguy in forum Excel General
    Replies: 0
    Last Post: 08-20-2012, 09:22 AM
  6. Check for data in cell. If found paste text into same row another column
    By Buddy7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2011, 02:38 PM
  7. Replies: 5
    Last Post: 08-27-2005, 06:05 AM

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