+ Reply to Thread
Results 1 to 6 of 6

How to repeat an action in other columns?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    How to repeat an action in other columns?

    Hi all,

    My question is rather simple I believe, but I'm really struggling to find a solution for that. Namely, I've got the following code that applies comma style in column J:

    'J applying comma style
    Dim Jcol As Long
    Application.ScreenUpdating = False
    Jcol = Cells(Rows.Count, "j").End(xlUp).Row
    For j = 11 To Jcol
        Cells(j, "j") = Format(Cells(j, "j"), "#,###")
    Next j

    and I need to repeat it in other columns, e.g. M, X, AG. Note: these columns are not next to each other, which makes the case a bit more complicated cause we cannot specify a simple range for that. Can you help me with that? Many thanks in advance.

    Vogelmann

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to repeat an action in other columns?

    No need of loop.... May be try like this...

    'J applying comma style
    Dim Jcol As Long
    
    Application.ScreenUpdating = False
    
    Jcol = Cells(Rows.Count, "j").End(xlUp).Row
    
    Range("J11:J" & Jcol).NumberFormat = "#,###"


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: How to repeat an action in other columns?

    It works, thank you. But the main problem remains unsolved - I'm sure there's a simple code for that but my memory isn't serving me well today..

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to repeat an action in other columns?

    May be like this...

    Range("J11:J" & Jcol).NumberFormat = "#,###"
    Range("M11:M" & Jcol).NumberFormat = "#,###"
    Range("X11:X" & Jcol).NumberFormat = "#,###"
    Range("AG11:AG" & Jcol).NumberFormat = "#,###"

  5. #5
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: How to repeat an action in other columns?

    thank you sixthsense, topic solved

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to repeat an action in other columns?

    Glad it helps you and thanks for the feedback and rep

+ 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. Repeat last action
    By Teri in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-13-2006, 11:15 AM
  2. repeat an action in different locations
    By countrypotter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  3. repeat an action in different locations
    By countrypotter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 PM
  4. repeat an action in different locations
    By countrypotter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] repeat an action in different locations
    By countrypotter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 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