Column Code

  • Thread starter Thread starter DaveB
  • Start date Start date
D

DaveB

I have 2 columns in my worksheet:
Column A Column B
10 TRUE
0 FALSE
4 TRUE
0 FALSE
2 TRUE

For every FALSE in column B, I would like column A to be
-997.

Thanks in advace for the code.
DaveB
 
A number of ways to do this. How about filtering on False in column B
and then enter -997 in all the found rows
 
One way

for each c in [b2:b200]
if ucase(c)="FALSE" then c.offset(,-1).value=-997
next
 
Dave,

Sub Falser()
Dim lrow As Long, x As Long

' determine number of rows
lrow = Cells(Rows.Count, "A").End(xlUp).Row

' loop and replace
For x = 1 To lrow
If LCase(Cells(x, 2)) = "false" Then
Cells(x, 1) = -997
End If
Next
End Sub
 
Back
Top