Replace Values in range selection
Hello,
I have Cells E3:AE77 selected. How can I assess each cell in the range selected and if the cell value is 0 then change the cell value to 0. Also, how do I have the macro stop after all the cells in the range have been assessed. Thank you all for your help! Terri |
Replace Values in range selection
For Each cell In Range("E3:AE77")
If cell.Value 0 Then cell.Value = 0 Next cell -- HTH RP (remove nothere from the email address if mailing direct) "Terri" wrote in message ... Hello, I have Cells E3:AE77 selected. How can I assess each cell in the range selected and if the cell value is 0 then change the cell value to 0. Also, how do I have the macro stop after all the cells in the range have been assessed. Thank you all for your help! Terri |
Replace Values in range selection
Enter this small macro:
Sub Macro1() Dim r As Range For Each r In Selection If r.Value 0 Then r.Value = 0 End If Next End Sub Select any range of cells and run the macro. -- Gary''s Student "Terri" wrote: Hello, I have Cells E3:AE77 selected. How can I assess each cell in the range selected and if the cell value is 0 then change the cell value to 0. Also, how do I have the macro stop after all the cells in the range have been assessed. Thank you all for your help! Terri |
Replace Values in range selection
Bob & "Gary's Student",
Both suggestions worked perfectly. Thank you both so much for the help and for getting me on the right path to other ways to use this code. Thanks again! Terri "Bob Phillips" wrote: For Each cell In Range("E3:AE77") If cell.Value 0 Then cell.Value = 0 Next cell -- HTH RP (remove nothere from the email address if mailing direct) "Terri" wrote in message ... Hello, I have Cells E3:AE77 selected. How can I assess each cell in the range selected and if the cell value is 0 then change the cell value to 0. Also, how do I have the macro stop after all the cells in the range have been assessed. Thank you all for your help! Terri |
All times are GMT +1. The time now is 02:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com