ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro: If (https://www.excelbanter.com/excel-programming/318930-macro-if.html)

Philipp Oberleitner

Macro: If
 
Hi all,
i have a problem with the floowing code

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value 10 Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value = 0 And (wks1.Cells(i, "B") Is Not "unbekannt")
Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

The first part works fine but the second part brings a type error
Isnt it possible to examine if Column O has value 0 and Column B /=
"unbekannt"

Thanks alot in advance

philipp



Bob Phillips[_6_]

Macro: If
 
It is, but you have to get the syntax correct

If wks1.Cells(i, "O").Value = 0 And (wks1.Cells(i, "B").Value <
"unbekannt")


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Philipp Oberleitner" wrote in message
...
Hi all,
i have a problem with the floowing code

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value 10 Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value = 0 And (wks1.Cells(i, "B") Is Not

"unbekannt")
Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

The first part works fine but the second part brings a type error
Isnt it possible to examine if Column O has value 0 and Column B /=
"unbekannt"

Thanks alot in advance

philipp





AA2e72E

Macro: If
 
I think you need:

If wks1.Cells(i, "O").Value = 0 And (wks1.Cells(i, "B") < "unbekannt")



"Philipp Oberleitner" wrote:

Hi all,
i have a problem with the floowing code

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value 10 Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

For i = 5 To wks1.Cells(Rows.Count, "O").End(xlUp).Row
If wks1.Cells(i, "O").Value = 0 And (wks1.Cells(i, "B") Is Not "unbekannt")
Then
iAnz = iAnz + 1
wks2.Rows(iAnz).Value = wks1.Rows(i).Value
End If
Next i

The first part works fine but the second part brings a type error
Isnt it possible to examine if Column O has value 0 and Column B /=
"unbekannt"

Thanks alot in advance

philipp





All times are GMT +1. The time now is 09:52 AM.

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