Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Macro to clear contents and put an X

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Macro to clear contents and put an X

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!*


"bevchapman" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro to clear contents and put an X

Sub relativee()
n = ActiveCell.Row
Range("E" & n & ":N" & n).ClearContents
Range("P" & n).Value = "X"
Range("P" & n + 1).Select
End Sub
--
Gary''s Student - gsnu200839
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Macro to clear contents and put an X

Thank you! Works perfect!

"Luke M" wrote:

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!*


"bevchapman" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
Macro to clear contents of unprotected cells AND drop down boxes JB2010 Excel Discussion (Misc queries) 3 March 30th 06 10:13 AM
HOW DO I PROTECT VALUES WHEN CREATING CLEAR CONTENTS MACRO? the holster Excel Discussion (Misc queries) 1 February 20th 06 06:33 PM
Clear Contents Macro SJC Excel Worksheet Functions 3 October 27th 05 07:26 PM
Clear Contents But Not Formula Gancom3 Excel Discussion (Misc queries) 2 February 1st 05 11:30 PM


All times are GMT +1. The time now is 09:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"