Macro repeating

  • Thread starter Thread starter Bob
  • Start date Start date
Give some idea of what you are trying to get to repeat, and post the code you
have so far.
 
Ken,

I'm trying to cut the data in a cell and paste it into
another cell in the next column and repeat this through
the spreadsheet.

Bob
 
OK - You are really going to have to help me out here with examples, as I could
put a number of solutions around what you have described, with code, formulas
and built in functions each being able to do what you have just asked depending
on the data and the criteria for the cut.

At the moment I'm leaning towards a Data / Text To Columns solution depending on
the delimiters.
 
Ken,

Cutting the contents of cell D4 and pasting to cell E3,
going to cell D7 cutting the contents of it and pasting
to cell E6 and so on for the rest of the spreadsheet.
Everything is uniform as far as the number of lines down
to the next cell that is going to be cut.

Bob
 
OK:-


Sub MoveData()

Dim r As Long
Dim lrow As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

lrow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row

For r = 4 To lrow Step 3
Cells(r - 1, 5).Value = Cells(r, 4).Value
Cells(r, 4).ClearContents
Next r

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub


This starts in D4 and works its way down 3 cells at a time (r = 4 To lrow Step
3). The 5 is Column E and the 4 is column D. Cells(r, 4) is a particular row
in Col D depending on what value r has at the time.
 
Back
Top