If text, then select entire row + run makro

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
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,225,247
Messages
6,183,841
Members
453,192
Latest member
BenToB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top