Finding "CL" or "CLOSED" in one clumn and changing to 99% in Another

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Code:
For i = 9 To LastRow
If UCase(Cells(i, "F")) <> "CL" Or UCase(Cells(i, "F")) <> "CLOSED" _
And Cells(i, "B").Value = 100 Then
Cells(i, "B").Value = 99 _
And Cells(i, "E").Formula = "=(E-.3)"
End If
Next i

Hello All...
I have a little problem here.
What I'm trying to accomplish, is for the macro to not find either "CL" or "CLOSED" (upper case should not matter) in column "F" and a 100% in column "B", and changing 100% in Column "B" to a 99%, and then subtracting a .3 from the number in Column E...one row at a time.
The loop is working correctly.

Column "B" is formatted previously with:
Code:
With Range("B9:B6000")
        .Formula = "=1-(C9/D9)"
        .NumberFormat = "0%"
End With

What's happening, is every cell in Column "B", as the loop moves row-to-row, changes the number in column "B", regardless if it's 100% to 0%, and Column "E" number is not getting .3 subtracted.

Where am I going wrong this time!
Thanks for the help
excel 2013
 
Last edited:
Check the value in col B, it probably isn't 1.


You're correct, the value was 99.7% and rounding up to 100%. I'm going to try putting in a greater than or equal to .995 and see if it works:

Code:
If Not IsError(Cells(i, "B").Value) Then
      If UCase(Cells(i, "F")) <> "CL" And UCase(Cells(i, "F")) <> "CLOSED" _
         And Cells(i, "B").Value >= 0.995 Then
            Cells(i, "B").Value = 0.99
            Cells(i, "E") = Cells(i, "E") - 0.3
      End If
   End If
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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