+ Reply to Thread
Results 1 to 6 of 6

Macro to select columns, call a macro, then shift 11 columns and run again in loop

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Macro to select columns, call a macro, then shift 11 columns and run again in loop

    Hi everyone,

    I already have the macro I want to call. What I'm trying to do is write a macro which will select a group of columns, say B:G, call the macro I already have, then shift 11 columns over, run the macro again, and continue shifting over 11 columns until the userange is empty. I've tried to do some research on this but I can't seem to find anything that quite matches.

    Any ideas?

    Thanks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to select columns, call a macro, then shift 11 columns and run again in loop

    Sub G()
      Dim r As Range
      
      Set r = Range("B:G")
      
      Do While WorksheetFunction.CountA(r)
        r.Select
        Call Groovicles
        Set r = r.Offset(, 11)
      Loop
    End Sub
    
    Sub Groovicles()
      ' ...
    End Sub
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Macro to select columns, call a macro, then shift 11 columns and run again in loop

    Hi shg,

    Thanks. Your code seems to work in the beginning, but the group of columns loses their range has it moves across the worksheet. So there's 6 columns in B:G, this range of 6 columns needs to keep shifting down 11 columns until the its blank.

    Any ideas?

    Thanks!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to select columns, call a macro, then shift 11 columns and run again in loop

    That's what it does for me. What does Groovicles do?

  5. #5
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Macro to select columns, call a macro, then shift 11 columns and run again in loop

    Ah, I should have put 10 instead of 11. Works perfect. Thanks shg!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to select columns, call a macro, then shift 11 columns and run again in loop

    You're welcome.

+ 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. How can I loop my Macro for all columns?
    By ataylor36 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2015, 05:57 PM
  2. [SOLVED] macro to shift data to adjacent columns based on dates
    By hommeg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2015, 06:14 PM
  3. [SOLVED] Macro to unhide columns, call a macro, then revert columns to previous state.
    By kjg in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2014, 10:02 AM
  4. macro to shift columns in sequence
    By pockethands in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2014, 06:11 PM
  5. Macro to Shift Columns based on Rank Value
    By eemrun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2013, 07:11 AM
  6. Macro stops working after rows/columns hidden call
    By stefsj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2011, 07:52 PM
  7. Match two columns with macro and shift cells down
    By cheerockracy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2009, 05:58 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