If statement isn't working, a helpful nudge needed

Jamie1

New Member
Joined
Feb 9, 2016
Messages
4
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:
ABCDEFGHIJKL
680394533.7510.28310.283FALSE5001.614-50
681424539.37512.18712.187TRUE50120.1334.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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Jamie

Try removing the "" around TRUE.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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