View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Brent McIntyre Brent McIntyre is offline
external usenet poster
 
Posts: 23
Default Macro To Copy Down

James,

The following code should do what you require.

If you have any queries let me know, I have tested it in
Excel 2002 and it works fine.

Yours sincerely,

Brent McIntyre

Create a CommandButton on the worksheet called
CommandButton_Process, then in VBA go to the worksheet you
put the button on and place the following code.

Public Sub CommandButton_Process_Click()

Dim Row_Count_Current As Long
Dim Row_Count_Final As Long
Dim Value_Current
Row_Count_Current = 1
Row_Count_Final = ActiveWorkbook.ActiveSheet.Cells
(Rows.Count, 1).End(xlUp).Row

While Row_Count_Current < Row_Count_Final + 1

If ActiveWorkbook.ActiveSheet.Range("A" &
Row_Count_Current) = "" Then

ActiveWorkbook.ActiveSheet.Range("A" &
Row_Count_Current) = Value_Current

Else

Value_Current =
ActiveWorkbook.ActiveSheet.Range("A" & Row_Count_Current)

End If

Row_Count_Current = Row_Count_Current + 1

Wend

End Sub