View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Stephen Rasey[_2_] Stephen Rasey[_2_] is offline
external usenet poster
 
Posts: 41
Default Macro moving down the sheet cell by cell

You will need to post your code because you must change some of the recorded
code to change the copy reference.

The secret will be to create a parent subrouting that moved to each new
selection, then
executes your copy-paste subroutine.

How do you want to tell it the range of cells to operate on? With a named
range.
Have the user highlight some cells and cycle through the cells?

You have a block of cells you select to start and it will loop until it
finds a row with a blank cell in the first column.

Sub CycleCells()
Dim rngTarget As Range
Set rngTarget = Selection

Set rngTarget = rngTarget.Resize(1, 3) 'change the selection to 1 row
by 3 cells.

Do Until (rngTarget.Cells(1, 1) = "" Or IsEmpty(rngTarget.Cells(1, 1)))
rngTarget.Select 'optional, only if you want to see it
change the selection
'MyCopyPaste rngTarget
'move the selection down one row
Set rngTarget = rngTarget.Offset(1, 0)
DoEvents '(always put this in a loop to make the computer list to
the keyboard and mouse)
Loop

End Sub

Stephen Rasey
Houston
http://wiserways.com
http://excelsig.org




"berlead " wrote in message
...
I have successfully created a macro that copies and pastes data from
three columns of a row into a single entry in a single cell in that
same row. I am trying to get this macro to perform the same function
in multiple cells directly beneath the row where I recorded it. For
example, I have it working in row 3. I want it to perform the same
function in rows 4 through 200.

How do I get it to move down one row, execute, move down one row,
execute, move down one row, execute etc and stay row relative...?

When I run the macro now, it always returns to row 3 and executes.

I am not a programmer and have very limited experience with macros (as
you can probably tell).

Thanks!


---
Message posted from http://www.ExcelForum.com/