Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-04-2009, 08:10 PM
Othelloguy Othelloguy is offline
Registered User
 
Join Date: 04 Jul 2009
Location: Mexico
MS Office Version:Excel 2003
Posts: 1
Othelloguy is becoming part of the community
Macro Help- Select Every 24th Cell

Please Register to Remove these Ads

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 09:51 PM.
Reply With Quote
  #2  
Old 07-04-2009, 09:11 PM
shg's Avatar
shg shg is online now
Forum Guru
 
Join Date: 20 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 18,546
shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay
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.
__________________
Entia non sunt multiplicanda sine necessitate.
Reply With Quote
  #3  
Old 07-05-2009, 12:45 AM
Ancalagon12321 Ancalagon12321 is offline
Registered User
 
Join Date: 03 Jul 2009
Location: London, England
MS Office Version:Excel 2003
Posts: 17
Ancalagon12321 is becoming part of the community
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.
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump