+ Reply to Thread
Results 1 to 16 of 16

Change number format for every 2nd column

  1. #1
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Change number format for every 2nd column

    Hi,

    currently I have the following code that allows me to change the number format to % for each range.

    However, I now need to insert a column after each initial column, and this number format will be $.00

    So how can I amend the code to ensure each column has the desired format?

    Please Login or Register  to view this content.
    Now I need for % format: col D,F, H, J,L,N, etc.

    and $ format for col E,G,I,K,M, etc.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Change number format for every 2nd column

    How about this ?

    Please Login or Register  to view this content.
    Then for the $ format the same but starting from 5 instead of 4.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    thanks bakerman.

    It works until it gets to col I but then I have a blank col (J) and it starts again from K:P. This is followed by a few more blanks. Col K shows % but then so does L and then I have $ format in col M and % in Col P. Perhaps I haven't done it correctly?

    I am using:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Change number format for every 2nd column

    hmmmm set first two columns then copy and paste special for the rest?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Change number format for every 2nd column

    Now I need for % format: col D,F, H, J,L,N, etc.

    and $ format for col E,G,I,K,M, etc.
    No probs here, every second column has the correct format.
    Or else I'm missing something.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    Quote Originally Posted by bakerman2 View Post
    No probs here, every second column has the correct format.
    Or else I'm missing something.

    Please Login or Register  to view this content.
    thanks but I tried this again and when it reaches col K it is in $ format. This throws the rest out.

    Col J is blank but I noticed it is in % format. So perhaps I need to account for this blank column as it should start with % again from col K?

  7. #7
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    it should start out as every second column, but the problem is then the ranges change. So it starts with col D-I (and this works fine), then K-P, then V-AA, then AC-AH, AN-AS, and so on.
    Last edited by maym; 09-28-2017 at 09:05 PM.

  8. #8
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Change number format for every 2nd column

    how about

    Please Login or Register  to view this content.
    HTH,
    Maud

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Change number format for every 2nd column

    Why didn't you mention this in your opening post ????
    This is something completely different then what you first said.
    So basically you have 6 filled columns - 1 blank - 6 filled columns -5 blank - 6 filled columns - 1 blank .....and so on.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Change number format for every 2nd column

    account for the blanks....
    Please Login or Register  to view this content.
    i'm sure the "I" structure can be done algebraically ..but left it as is so you can follow why its being changed like it is
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    Quote Originally Posted by bakerman2 View Post
    Why didn't you mention this in your opening post ????
    This is something completely different then what you first said.
    So basically you have 6 filled columns - 1 blank - 6 filled columns -5 blank - 6 filled columns - 1 blank .....and so on.
    sorry yes, I wasn't clear in my opening post. Apologies.

    Yes, this is how it is set out. 6 filled columns, 1 blank, 6 filled columns, 5 blank, and so on.

  12. #12
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    Quote Originally Posted by humdingaling View Post
    account for the blanks....
    Please Login or Register  to view this content.
    i'm sure the "I" structure can be done algebraically ..but left it as is so you can follow why its being changed like it is
    thanks humdingaling. Yes that will work, the only problem is that I have over 100 columns, so I will need to go and add more of the "I" structure to account for this.

  13. #13
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Change number format for every 2nd column

    sorry did testing didnt work properly refer to next post
    Last edited by humdingaling; 09-28-2017 at 10:16 PM.

  14. #14
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Change number format for every 2nd column

    try this instead

    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Change number format for every 2nd column

    Please Login or Register  to view this content.
    mod and k not required as i reset counter in code
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Change number format for every 2nd column

    perfect humdingaling! Seems to be working fine, but I will do some more testing. Thanks so much for your help

+ 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. Show Error when a cell with number format change to date format
    By delroba in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2015, 02:57 AM
  2. [SOLVED] Change format into a Europe Number Format and divide with 1000
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-16-2015, 05:26 AM
  3. change number format based on content of another column using vba
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2014, 10:51 AM
  4. Replies: 1
    Last Post: 12-05-2013, 07:51 PM
  5. Replies: 3
    Last Post: 05-15-2013, 12:16 AM
  6. How to change a - number format to a positive number format ?
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2011, 10:14 AM
  7. Replies: 1
    Last Post: 05-18-2006, 11:45 PM

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