Macro to clear contents and put an X

  • Thread starter Thread starter bevchapman
  • Start date Start date
B

bevchapman

I can get a macro to work on one row but I want to be able to use on any row.
Here is what i have so far:
Range("E19:N19").Select
Selection.ClearContents
Range("P19").Select
ActiveCell.FormulaR1C1 = "X"
Range("P20").Select

I want to be able to be on any row, whether it be Row 19 or Row 700 and be
able to run this. The column will stay the same.
 
This will clear contents of columns E:N of whatever row you are currently on,
and put a "X" in the P column. Not sure if you really needed the cell below
the "X" selected or not, but I included it anyway.

Range("E" & ActiveCell.Row & ":N" & ActiveCell.Row).ClearContents
Range("P" & ActiveCell.Row).Value = "X"
Range("P" & ActiveCell.Row+1).Select

If you're detemrining the row via the macro, simply replace 'ActiveCell.Row'
with a number/variable.
 
Sub relativee()
n = ActiveCell.Row
Range("E" & n & ":N" & n).ClearContents
Range("P" & n).Value = "X"
Range("P" & n + 1).Select
End Sub
 
Thank you! Works perfect!

Luke M said:
This will clear contents of columns E:N of whatever row you are currently on,
and put a "X" in the P column. Not sure if you really needed the cell below
the "X" selected or not, but I included it anyway.

Range("E" & ActiveCell.Row & ":N" & ActiveCell.Row).ClearContents
Range("P" & ActiveCell.Row).Value = "X"
Range("P" & ActiveCell.Row+1).Select

If you're detemrining the row via the macro, simply replace 'ActiveCell.Row'
with a number/variable.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*
 
Back
Top