View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Darren Ingram Darren Ingram is offline
external usenet poster
 
Posts: 13
Default Coding to choose the previous completed cell in a column

Hi,

I have used the Macro recorder to create a macro for me however when I apply
the macro to other similar worksheets in bombs out. What I have recorded is
for the macro in whatever column to go back to column A in the row and then
go up to the previously filled cell in column A and complete a set function.

What the recorder records is a change in the number of cells (0, -15) or
whatever and it then applies that movement change to all future runnings.

Coding is as follows ( I hope this helps)

ActiveCell.Offset(0, 1).Range("A1:I1").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
ActiveCell.Offset(0, 9).Range("A1:B1").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.Offset(0, 5).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.Offset(0, -15).Range("A1").Select
Selection.Cut
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Range("A1").Select
Selection.ClearContents
End Sub

I don't want it to recorded the number of times I've moved up...just the
fact that I've moved up. When I recorded it I use the Ctrl+(up arrow) to
record the movement however it has given this a literal value of -15.

I am trying to move around the worksheet using Ctrl+ and each time is does
the above. I'm also selecting cells in a similar way by selecting the cell
in a column (That is blank) and doing a Shift+Ctrl+up arrow and doing a
Ctrl+D to fill the calculations held in the first cell.

This also doesn't work as it's taking literal cell movements.

I hope that someone is able to help me