Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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
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
Range of Values with different column selection CharlieR Excel Discussion (Misc queries) 1 June 3rd 09 07:14 AM
how do I find and replace within a selection in Excel 2007? geoff Excel Discussion (Misc queries) 4 December 8th 08 11:54 PM
Selection.Replace Problem Dave Excel Discussion (Misc queries) 8 September 20th 07 06:23 PM
Excel: Add replace within selection functionality Marcel XL Excel Discussion (Misc queries) 1 March 3rd 06 01:51 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 07:42 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"