Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How to repeat a macro

I have a macro that looks like this:

ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-2, 1).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-4, 2).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-6, 3).Range("A1")
ActiveCell.Offset(-5, 0).Rows("1:8").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(0, 2).Range("A1").Select

I'd like to have Excel repeat the macro for as many entries there are on the
spreadsheet (this macro being valid onl for one entry). Right now I do it
manually by pressing a shortcut for as long as it not done.

Any help will be gratefully appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to repeat a macro


range("A1").select
do until selection.value=""
'your code
selection.offset(1,0).select
loop


--
davesexcel


------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=557698

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default How to repeat a macro

I don't know if its the best way but you could try the following (which
presumes that the you want to carry on until the active cell is empty): -

sub test()
Dim numcheck
numcheck = ActiveCell.Value
Do Until numcheck = ""

'<== YOUR CODE HER ==

ActiveCell.Offset(1, 0).Select '<== or whatever your offset is
numcheck = ActiveCell.Value
Loop
end sub

hope this helps,

Tim


"Leon" wrote in message
...
I have a macro that looks like this:

ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-2, 1).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-4, 2).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-6, 3).Range("A1")
ActiveCell.Offset(-5, 0).Rows("1:8").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(0, 2).Range("A1").Select

I'd like to have Excel repeat the macro for as many entries there are on
the
spreadsheet (this macro being valid onl for one entry). Right now I do it
manually by pressing a shortcut for as long as it not done.

Any help will be gratefully appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How to repeat a macro

Tim,
You're going to think my question is dumb
but what does "Do Until numcheck = """
what do I have to replace """" by

Sorry I'm a beginner !!

"Tim Marsh" wrote:

I don't know if its the best way but you could try the following (which
presumes that the you want to carry on until the active cell is empty): -

sub test()
Dim numcheck
numcheck = ActiveCell.Value
Do Until numcheck = ""

'<== YOUR CODE HER ==

ActiveCell.Offset(1, 0).Select '<== or whatever your offset is
numcheck = ActiveCell.Value
Loop
end sub

hope this helps,

Tim


"Leon" wrote in message
...
I have a macro that looks like this:

ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-2, 1).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-4, 2).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-6, 3).Range("A1")
ActiveCell.Offset(-5, 0).Rows("1:8").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(0, 2).Range("A1").Select

I'd like to have Excel repeat the macro for as many entries there are on
the
spreadsheet (this macro being valid onl for one entry). Right now I do it
manually by pressing a shortcut for as long as it not done.

Any help will be gratefully appreciated.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default How to repeat a macro

there are no dumb questions (except the ones i ask)!

this is the same as davesexcel's route (except his would always refer to the
selected cell, whereas you could use mine to refer to something else if that
were relevant).

the 'Do Until numcheck = ""' statement just means that you keep on
processing the loop until you get to a blank cell ie, the contents of active
cell (that you have just scrolled to) = "" (ie, nothing in the cell)

hth,

Tim

"Leon" wrote in message
...
Tim,
You're going to think my question is dumb
but what does "Do Until numcheck = """
what do I have to replace """" by

Sorry I'm a beginner !!

"Tim Marsh" wrote:

I don't know if its the best way but you could try the following (which
presumes that the you want to carry on until the active cell is empty): -

sub test()
Dim numcheck
numcheck = ActiveCell.Value
Do Until numcheck = ""

'<== YOUR CODE HER ==

ActiveCell.Offset(1, 0).Select '<== or whatever your offset is
numcheck = ActiveCell.Value
Loop
end sub

hope this helps,

Tim


"Leon" wrote in message
...
I have a macro that looks like this:

ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-2, 1).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-4, 2).Range("A1")
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(-6, 3).Range("A1")
ActiveCell.Offset(-5, 0).Rows("1:8").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(0, 2).Range("A1").Select

I'd like to have Excel repeat the macro for as many entries there are
on
the
spreadsheet (this macro being valid onl for one entry). Right now I do
it
manually by pressing a shortcut for as long as it not done.

Any help will be gratefully appreciated.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro repeat decimal Excel Worksheet Functions 2 May 21st 09 11:53 PM
Repeat a Macro Victoria[_3_] Excel Worksheet Functions 1 September 25th 07 07:11 PM
How to get a macro to repeat \\sh Excel Discussion (Misc queries) 2 November 6th 06 05:04 PM
How can I repeat a macro? emil Excel Programming 2 April 18th 06 01:03 AM
Repeat Macro tvkodde26 Excel Worksheet Functions 5 October 19th 05 07:37 PM


All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"