ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column Code (https://www.excelbanter.com/excel-programming/280389-column-code.html)

DaveB[_2_]

Column Code
 
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


DavidP[_3_]

Column Code
 
A number of ways to do this. How about filtering on False in column B
and then enter -997 in all the found rows

On Thu, 23 Oct 2003 07:48:45 -0700, "DaveB"
wrote:

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



Don Guillett[_4_]

Column Code
 
One way

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

"DaveB" wrote in message
...
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




steve

Column Code
 
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

--
sb
"DaveB" wrote in message
...
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





All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com