ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If then VB statement (https://www.excelbanter.com/excel-programming/383847-if-then-vbulletin-statement.html)

bill ch

If then VB statement
 
My attempt doesn't work:

If Columns("B:B") = "A" And Columns("N:N") = "manual Calc" Then
Columns("O:O") = "0"

I need it to see if column B has value "A" in it with a matching row of
column N with value "manual Calc" and if true then set the same rows column O
to a value of "0".
Thanks in advance for your expert advice!

Mike

If then VB statement
 
try this for-next loop.

Sub readcolumns()
For x = 1 To 65536
If Worksheets("Sheet1").Cells(x, 2).Text = "B" And _
Worksheets("Sheet1").Cells(x, 14).Text = "manual calc" Then
Worksheets("Sheet1").Cells(x, 15).Value = "o"
flag = 1
End If
Next
End Sub

Mike

"bill ch" wrote:

My attempt doesn't work:

If Columns("B:B") = "A" And Columns("N:N") = "manual Calc" Then
Columns("O:O") = "0"

I need it to see if column B has value "A" in it with a matching row of
column N with value "manual Calc" and if true then set the same rows column O
to a value of "0".
Thanks in advance for your expert advice!


bill ch

If then VB statement
 
Works like magic! Thanks a ton for your help!

"Mike" wrote:

try this for-next loop.

Sub readcolumns()
For x = 1 To 65536
If Worksheets("Sheet1").Cells(x, 2).Text = "B" And _
Worksheets("Sheet1").Cells(x, 14).Text = "manual calc" Then
Worksheets("Sheet1").Cells(x, 15).Value = "o"
flag = 1
End If
Next
End Sub

Mike

"bill ch" wrote:

My attempt doesn't work:

If Columns("B:B") = "A" And Columns("N:N") = "manual Calc" Then
Columns("O:O") = "0"

I need it to see if column B has value "A" in it with a matching row of
column N with value "manual Calc" and if true then set the same rows column O
to a value of "0".
Thanks in advance for your expert advice!


Mike

If then VB statement
 
Your welcome and thanks for the feedback.

"bill ch" wrote:

Works like magic! Thanks a ton for your help!

"Mike" wrote:

try this for-next loop.

Sub readcolumns()
For x = 1 To 65536
If Worksheets("Sheet1").Cells(x, 2).Text = "B" And _
Worksheets("Sheet1").Cells(x, 14).Text = "manual calc" Then
Worksheets("Sheet1").Cells(x, 15).Value = "o"
flag = 1
End If
Next
End Sub

Mike

"bill ch" wrote:

My attempt doesn't work:

If Columns("B:B") = "A" And Columns("N:N") = "manual Calc" Then
Columns("O:O") = "0"

I need it to see if column B has value "A" in it with a matching row of
column N with value "manual Calc" and if true then set the same rows column O
to a value of "0".
Thanks in advance for your expert advice!


Stan Lo

If then VB statement
 
Hi Mike

What does the flag=1 do?

thanks
Slo

?B?TWlrZQ==?= wrote in
:

Your welcome and thanks for the feedback.

"bill ch" wrote:

Works like magic! Thanks a ton for your help!

"Mike" wrote:

try this for-next loop.

Sub readcolumns()
For x = 1 To 65536
If Worksheets("Sheet1").Cells(x, 2).Text = "B" And _
Worksheets("Sheet1").Cells(x, 14).Text = "manual calc" Then
Worksheets("Sheet1").Cells(x, 15).Value = "o"
flag = 1
End If
Next
End Sub

Mike

"bill ch" wrote:

My attempt doesn't work:

If Columns("B:B") = "A" And Columns("N:N") = "manual Calc" Then
Columns("O:O") = "0"

I need it to see if column B has value "A" in it with a matching
row of column N with value "manual Calc" and if true then set the
same rows column O to a value of "0".
Thanks in advance for your expert advice!





All times are GMT +1. The time now is 05:34 AM.

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