ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select a different range each time (https://www.excelbanter.com/excel-programming/273235-re-select-different-range-each-time.html)

Don Guillett[_4_]

select a different range each time
 
more info would help.

--
Don Guillett
SalesAid Software
Granite Shoals, TX

"Joy Chen" wrote in message
...
Hi,

I like to write a micro that will select a range of cells
based on a starting point/cell that I assign each time
and perform repetitive data sorting for me from there.
Any help would be appreciated. Thank you.

Joy




Joy Chen

select a different range each time
 
I have segments of data in my spreadsheet that contain similar
information and require to be organized in the similar fashion. It
would be nice if I can write a macro so that each time I can sort a
fixed size of range starting at the beginning of each segment. Thank
you.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

ibeetb

select a different range each time
 
The way that works for me, which may not be the BEST way is: For the other
ranges I want to loop through, I select the starting cell of the following
ranges, in code, one at a time: Example Range("A1").select. This would then
make it the active cell . I would then loop down the range and perform
whatever action I wanted.....
"Joy Chen" wrote in message
...
I have segments of data in my spreadsheet that contain similar
information and require to be organized in the similar fashion. It
would be nice if I can write a macro so that each time I can sort a
fixed size of range starting at the beginning of each segment. Thank
you.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Tom Ogilvy

select a different range each time
 
that is what was suggested - but I believe the poster was assuming you would
process the whole sheet.

If you want to designate the range to work on by selecting it, then you can
make your macro use references like

ActiveCell

Selection and so forth.

then you wouldn't have to change anything in the code.

Regards,
Tom Ogilvy


Joy Chen wrote in message
...
Do you mean going into the micro each time and manually change the
select cell, e.g. "A1", to the disired new location?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




ibeetb

select a different range each time
 
or you could....
Have your macro select the first cell of each range, one at a time and after
each swelection, run the following:
Ex: Range("E5").select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop

The row of cells under E5, like e6,e7,e8 would be selected one a t a time
and then some action performed......

after this, have the macro select the first cell of the NEXT range.....and
follow the same code


"Tom Ogilvy" wrote in message
...
Turn on the macro recorder (tools=Macro=Record a new macro)
Select the upper left corner of one of the ranges,
Then do Data=sort

the turn off the macro recorder

Adapt the macro to do any additional processing you require.

Regards,
Tom Ogilvy


Joy Chen wrote in message
...
I have segments of data in my spreadsheet that contain similar
information and require to be organized in the similar fashion. It
would be nice if I can write a macro so that each time I can sort a
fixed size of range starting at the beginning of each segment. Thank
you.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!






ibeetb

select a different range each time
 
I forgot to add: Before your Loop statement, place your code to perform
whatever action you want
Ex:Ex: Range("E5").select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
'Perform some action

Loop
Works like a charm for me ewverytime

"ibeetb" wrote in message
...
or you could....
Have your macro select the first cell of each range, one at a time and

after
each swelection, run the following:
Ex: Range("E5").select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop

The row of cells under E5, like e6,e7,e8 would be selected one a t a time
and then some action performed......

after this, have the macro select the first cell of the NEXT range.....and
follow the same code


"Tom Ogilvy" wrote in message
...
Turn on the macro recorder (tools=Macro=Record a new macro)
Select the upper left corner of one of the ranges,
Then do Data=sort

the turn off the macro recorder

Adapt the macro to do any additional processing you require.

Regards,
Tom Ogilvy


Joy Chen wrote in message
...
I have segments of data in my spreadsheet that contain similar
information and require to be organized in the similar fashion. It
would be nice if I can write a macro so that each time I can sort a
fixed size of range starting at the beginning of each segment. Thank
you.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!








Joy Chen

select a different range each time
 
Thanks for previous reply and help!

I now would like to design a micro to paste 3 consecutive cells based on
a word found in the first of the cells.

I figure I can use the Find function (Ctrl+F) on a spreadsheet to find
the word. How then could I select the cell that contains the word and
copy the cells and the two cells next to it.

I know I should put the Find function and related detail in a loop.
Here is what I have so far. Could you check for me and help me to
program the rest.

Sheets("MET23").Select
Range("A2").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Sheets("").Select
Cells.Find(What:="MET", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
).Activate
Cells.FindNext(After:=ActiveCell).Activate

Range(????).Select
Selection.Copy
Sheets("MET32").Select

Loop

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com