Macro to change a cell value to 0.00 if another cell has a certain name in it.

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,079
Office Version
  1. 365
Platform
  1. Windows
Trying to change a certain column of row cells to "0.00" 0.00
So lets say H11,H20,H30 have the word "D (Checking)" in it. Then in cells E11,E20,E30 would like to change the cell values to 0.00
I can do an =IF formula in another column and get the results, but im trying to change what i need changed in Column E because i need to leave certain cells alone.
Think i would need to do a small macro so it changes only the cells i indicate above.

Looks like:

Excel 2016 (Windows) 32 bit
E
F
G
H
9
$ 1,352.93 0
10
$ 869.67 0
11
$ 1,004.06 0D (Checking)
12
$ 548.58 1623
13
$ 1,114.32 21608
Sheet: Formulas

What I need it to look like:

Excel 2016 (Windows) 32 bit
E
F
G
H
9
$ 1,352.93 0
10
$ 869.67 0
11
$0.00
0D (Checking)
12
$ 548.58 1623
Sheet: Formulas

Column E cell changed to 0.00

Any help thanks
 
I probably could do an =if formula in another column and get the result. if d checking is in H then put 0.00 In E. The issue is i have other values in other cells in Col E. So copying and pasting the results i don't want to. I rather run a simple sub to change In Col E cells to 0.00 if name is in Col H. Maybe someone else can help me on this. I even looked it up online but i can't find exactly what i need by referencing from another cell.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi so I added more code and got it to work, but I'm trying to add another name to it. I tried AND or OR but doesn't work. I know I'm missing something small. Let me know if you see something I'm missing thanks again.


This works

Code:
Sub Change() 
Application.ScreenUpdating = False
  Dim i As Range
  Dim Cel As Range
  
  Set i = Range("H:H")
  If Not i Is Nothing Then
    For Each Cel In i
      If Cel.Value = "D (Checking)" Then
        Cells(Cel.Row, 5).Value = 0
      End If
    Next Cel
  End If
  Application.ScreenUpdating = True
    
End Sub



Code:
Sub Change2() 
Application.ScreenUpdating = False
  Dim i As Range
  Dim Cel As Range
  
  Set i = Range("H:H")
  If Not i Is Nothing Then
    For Each Cel In i
      If Cel.Value = "D (Checking)" or "D (Savings)" Then   '<-- when adding another name then it doesn't work maybe I'm missing , or something not sure. '
        Cells(Cel.Row, 5).Value = 0
      End If
    Next Cel
  End If
  Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Ha thanks alot I didn't think to use Cel.Value again. Thank again
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,186
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top