ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If-Then, with an OR --- not working! (https://www.excelbanter.com/excel-programming/394869-if-then-not-working.html)

Ray

If-Then, with an OR --- not working!
 
Hello -

This piece of code isn't working for me and I have NO idea why not:

iLastRow = ws.Cells(Rows.Count, 2).End(xlUp).Row
If ws.Name < "Home" Or iLastRow < 8 Then
<other code here
End If
Next ws

'ws' is defined as Worksheet and iLastRow is defined as Integer.

So, if the name of the Sheet is 'Home' OR if the LastRow is less than
8, the code should continue on with the next sheet. It works fine if
Sheet.name = Home, but proceeds through the normal code if iLastRow<8
and doing so causes an error.

What's wrong with my coding?

TIA,
Ray


Bernie Deitrick

If-Then, with an OR --- not working!
 
If ws.Name < "Home" Or iLastRow 8 Then


--
HTH,
Bernie
MS Excel MVP


"Ray" wrote in message
oups.com...
Hello -

This piece of code isn't working for me and I have NO idea why not:

iLastRow = ws.Cells(Rows.Count, 2).End(xlUp).Row
If ws.Name < "Home" Or iLastRow < 8 Then
<other code here
End If
Next ws

'ws' is defined as Worksheet and iLastRow is defined as Integer.

So, if the name of the Sheet is 'Home' OR if the LastRow is less than
8, the code should continue on with the next sheet. It works fine if
Sheet.name = Home, but proceeds through the normal code if iLastRow<8
and doing so causes an error.

What's wrong with my coding?

TIA,
Ray




Ray

If-Then, with an OR --- not working!
 
Thanks Bernie ... although now I feel like a fool ... ;)




Dave D-C[_3_]

If-Then, with an OR --- not working!
 
Ray wrote:
This piece of code isn't working for me and I have NO idea why not:
iLastRow = ws.Cells(Rows.Count, 2).End(xlUp).Row
If ws.Name < "Home" Or iLastRow < 8 Then
<other code here
End If
Next ws
So, if the name of the Sheet is 'Home' OR if the LastRow is less than
8, the code should continue on with the next sheet. It works fine if
Sheet.name = Home, but proceeds through the normal code if iLastRow<8
and doing so causes an error.


1) If ws.Name < "Home" Or iLastRow < 8 Then
2) So, if the name of the Sheet is 'Home' OR
if the LastRow is less than 8

1 doesn't match 2.
is NOT 'Home'?
is = 8?

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


All times are GMT +1. The time now is 06:37 AM.

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