+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    07-04-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro Help- Select Every 24th Cell

    I have a massive amount of feedback data from a simulation machine that needs to be reorganized. In order to do this efficiently, I need a macro that will select every 24th cell within a column from a relative reference point. This task would need to be done on an infinite loop. I have tried the "record macro" functions in Excel 2007 have been unsuccessful. The macro I tried was...
    Code:
    Do Until ActiveCell.Value = ""
        ActiveCell.Offset(1, 0).Range("A1,A25").Select
        ActiveCell.Offset(25, 0).Range("A1").Activate
        Loop
    End Sub
    However, this macro didn't actually activate every 24th cell (I'm not entirely sure what it did if it did anything). If someone could provide me with the code for a macro that would accomplish the aforementioned tasks I would really appreciate it.

    Thanks.
    Last edited by Othelloguy; 07-04-2009 at 10:51 PM.

  2. #2
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,130

    Re: Macro Help- Select Every 24th Cell

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-03-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro Help- Select Every 24th Cell

    Try the following.

    Code:
    Dim rng As Range: Set rng = ActiveCell
    Dim rngUnion As Range: Set rngUnion = ActiveCell
    Set rng = rng.Offset(24, 0)
    Do While Len(rng.Value) > 0
        Set rngUnion = Union(rngUnion, rng)
        Set rng = rng.Offset(24, 0)
    Loop
    rngUnion.Select
    Possible reasons why it might not work:

    (1) I don't know how many components a multiple range is allowed to have, so perhaps the table could be too large for it to be possible to select every 24th cell?

    (2) If your data extends right to the bottom of the sheet then presumably "rng.Offset(24, 0)" will cause an error at some point.

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.2.0