# If statement isn't working, a helpful nudge needed

#### Jamie1

##### New Member
Hi

I had a look in the forum but couldn't find a thread that would help (after trying some solutions in those threads)

An example of the cells I am trying to manipulate are below:
 A B C D E F G H I J K L 680 39 45 33.75 10.283 10.283 FALSE 50 0 1.614 -50 681 42 45 39.375 12.187 12.187 TRUE 50 12 0.133 4.702

The Do loop I have written populates the cells, pulling the data in from other sheets. But I need it to change column I to 0 if column H is populated with TRUE and column J has a value greater than 1. The coding I have tried is as follows:

Rich (BB code):
``````    rownum = 18
Do
rownum = rownum + 1
elstring = Cells(rownum, 4)
If elstring = "" Then Exit Do
el = Cells(rownum, 4)
bs = Cells(rownum, 5)
Kf = Cells(rownum, 6)

'Pick up the data and write to the target sheet
KFCheck = ReadKFCheck(el, bs)
Cells(rownum, 7) = KFCheck

PTFound = ReadPTFound(el, bs)
Cells(rownum, 8) = PTFound

punchThrough = ReadPunchThrough(el, bs)
Cells(rownum, 9) = punchThrough

NumPTAngles = ReadNumPTAngles(el, bs)
Cells(rownum, 10) = NumPTAngles \ 5#

If Cells(rownum, 8) = "TRUE" And Cells(rownum, 10) >= 1# Then
Cells(rownum, 9) = 0#
End If

BeamGainDepth = ReadBeamGainDepth(el, bs)
Cells(rownum, 11) = BeamGainDepth

PTMaxGain = ReadPTMaxGain(el, bs)
Cells(rownum, 12) = PTMaxGain

Loop``````

The code in red is what I have tried, and I have tried alternatives and nothing seems to be making the 50 change to 0. Does anyone have any ideas where I am going wrong?

Many thanks,

Jamie

### Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Jamie

Try removing the "" around TRUE.

Thank you, works perfectly. A bit of a frustrating mistake to make, I tried this but must have made a mistake elsewhere in my code and thought it was that it was the wrong thing.

Replies
15
Views
422
Replies
7
Views
436
Replies
0
Views
298
Replies
1
Views
223
Replies
1
Views
395

1,203,071
Messages
6,053,369
Members
444,658
Latest member
lhollingsworth

### 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?

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