Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Range of Values with different column selection | Excel Discussion (Misc queries) | |||
how do I find and replace within a selection in Excel 2007? | Excel Discussion (Misc queries) | |||
Selection.Replace Problem | Excel Discussion (Misc queries) | |||
Excel: Add replace within selection functionality | Excel Discussion (Misc queries) | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming |