raphagcwill
New Member
- Joined
- Jan 12, 2016
- Messages
- 41
Hi there,
would really appreciateyour help with the below.
I have found and changed to my needs the VBA i found here (excel - Filling any empty cells with the value above - Stack Overflow).
What it does is that i search on column N for the text "PPO". If true it copies the data on cells above.
The problem is that the macro only works when i select the row i want it to run... if I run the macro without selecting the row nothing happens
Is there any "easy" vba for selecting an entire row based on a text found on column N?
Sub copy_row_above()
Dim columnValues As Range, i As Long
Set columnValues = Selection
i = 1
For i = 1 To columnValues.rows.Count
If columnValues.Cells(i, 14).Value = "PPO" Then
columnValues.Cells(i, 3).Value = columnValues.Cells(i - 1, 3).Value
columnValues.Cells(i, 9).Value = columnValues.Cells(i - 1, 9).Value
columnValues.Cells(i, 10).Value = columnValues.Cells(i - 1, 10).Value
columnValues.Cells(i, 11).Value = columnValues.Cells(i - 1, 11).Value
columnValues.Cells(i, 12).Value = columnValues.Cells(i - 1, 12).Value
End If
Next
End Sub
Thank you so much in advance
Regards,
Raphael
would really appreciateyour help with the below.
I have found and changed to my needs the VBA i found here (excel - Filling any empty cells with the value above - Stack Overflow).
What it does is that i search on column N for the text "PPO". If true it copies the data on cells above.
The problem is that the macro only works when i select the row i want it to run... if I run the macro without selecting the row nothing happens
Is there any "easy" vba for selecting an entire row based on a text found on column N?
Sub copy_row_above()
Dim columnValues As Range, i As Long
Set columnValues = Selection
i = 1
For i = 1 To columnValues.rows.Count
If columnValues.Cells(i, 14).Value = "PPO" Then
columnValues.Cells(i, 3).Value = columnValues.Cells(i - 1, 3).Value
columnValues.Cells(i, 9).Value = columnValues.Cells(i - 1, 9).Value
columnValues.Cells(i, 10).Value = columnValues.Cells(i - 1, 10).Value
columnValues.Cells(i, 11).Value = columnValues.Cells(i - 1, 11).Value
columnValues.Cells(i, 12).Value = columnValues.Cells(i - 1, 12).Value
End If
Next
End Sub
Thank you so much in advance
Regards,
Raphael