PDA

View Full Version : Conditional Duplicating down a column



SGBurton123
10-05-2010, 09:02 AM
Brand new to Excel VBA, used Quattro Pro for years

Question : trying to duplicate the cell above the active cell down through a column until reaching a '999' stop ... the following isn't working for me :

Dim PSRegCell
For Each PSRegCell In Range("A1")
If ActiveCell.Value <> 999 Then
ActiveCell.Offset(-1, 0).Range("a1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Range("A1").Select
Else: End
End If

I know this is simple, but I've been handed a project for which I'm unprepared ... thanks !
Next PSRegCell

davmec93
10-05-2010, 01:33 PM
Hi, I have don't something similiar in one of my projects and used the following code. This should get you started but you may need to mod it a little. Select the column you want and then step thru it and see what you think.
Sub CopyData()

For i = 1 To 472 '
If Len(ActiveCell.Offset(i, 0)) = 0 Then
ActiveCell.Offset(i, 0) = strContent
Else
strContent = ActiveCell.Offset(i, 0)
End If
Next i
End Sub

davmec93
10-05-2010, 01:36 PM
Sub CopyData()

For i = 1 To 472 '
If Len(ActiveCell.Offset(i, 0)) = 0 Then
ActiveCell.Offset(i, 0) = strContent
Else
strContent = ActiveCell.Offset(i, 0)
End If
Next i
End Sub
[/quote]

Let me add that you will need to change
For i = 1 To 472
to
For i =1 To 999