need a macro

JasonLeVan

Board Regular
Joined
Feb 7, 2011
Messages
121
i need a macro that will look in column "N" starting in row 1 and if the number 0 appears then to change the cell in column "O" in the same row to a zero. thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about...

Code:
Sub ChangeZero()
    Dim LR As Long: LR = Range("N" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = 1 To LR
        If Range("N" & i).Value = 0 Then Range("O" & i).Value = 0
    Next i
End Sub
 
Upvote 0
Hello,

Try this on a copy.


<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> ZeroFinder()<br><br><SPAN style="color:#00007F">Dim</SPAN> c<br><br><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> Range("N:N")<br>    <SPAN style="color:#00007F">If</SPAN> c.Value = "0" <SPAN style="color:#00007F">Then</SPAN> c.Offset(0, 1).Value = 0<br><SPAN style="color:#00007F">Next</SPAN> c<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Without the quotes around the zero ("0"), it places a whole lot of zeros down col. O:O.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

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