Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding an 'And' to a code! 2

Status
Not open for further replies.

APElliott

Technical User
Jul 9, 2002
165
GB
Hello,

I,ve got the code below to stop a code from running if a cell = "".

How do I add to the code? [dazed]

I want it to exit the sub If ActiveCell.Offset(0, -15) = "" & if If ActiveCell.Offset(0, -13) is greater than 0

If ActiveCell.Offset(0, -15) = "" Then
Exit Sub
Else

Cheers,

Andrew [afro]
 
If ActiveCell.Offset(0, -15) = "" And _
If ActiveCell.Offset(0, -13) > 0 Then
Exit Sub
Else


Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Better practice is:

If isempty(ActiveCell.Offset(0, -15)) And _
If ActiveCell.Offset(0, -13) > 0 Then
Exit Sub
Else

That way you are truely looking if the cell is empty.

I hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Hi Andrew,

You just need to type in AND

If ActiveCell.Offset(0, -15) = "" And ActiveCell.Offset(0,-13) > 0 Then
Exit Sub
Else
...........

Cheers

John
 
Thanks Guys [bigcheeks]

Saved the day again.

The cell has a formula in it that sometimes = 0. Does this count as IsEmpty?

Thanks

Andrew [afro]
 
No Andrew, that counts as 0

Empty means empty!

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
[ROFL][ROFL]

Rgds, Geoff
[blue]Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?[/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top