Exit Sub if count less than zero.

Q

Qull666

Need help on this.

I don't want the Macro to work if [***IF COUNT(T4:T53) = 0 THEN EXIT SUB***]
inside the Macro below.


Sub SettleAutoDue()

***IF COUNT(T4:T53) = 0 THEN EXIT SUB***

Worksheets("A-3").Range("U4:Z4").Copy
Range("G5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Range("G4").Activate

End Sub


Thank you.
 
J

Jacob Skaria

Oops; please ignore the previous post....

COUNT() is a worksheet function.So ..

Sub SettleAutoDue()

If WorksheetFunction.Count(Range("T4:T53")) <> 0 Then
Worksheets("A-3").Range("U4:Z4").Copy
Range("G5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Range("G4").Activate
End If

End Sub
 
S

Stan

It works. Thanks Mike.

Mike H said:
try,

If WorksheetFunction.Count(Range("T4:T53")) = 0 Then Exit Sub

mike

Need help on this.

I don't want the Macro to work if [***IF COUNT(T4:T53) = 0 THEN EXIT SUB***]
inside the Macro below.


Sub SettleAutoDue()

***IF COUNT(T4:T53) = 0 THEN EXIT SUB***

Worksheets("A-3").Range("U4:Z4").Copy
Range("G5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Range("G4").Activate

End Sub


Thank you.
 
S

Stan

It works. Thanks Jacob

Jacob Skaria said:
Oops; please ignore the previous post....

COUNT() is a worksheet function.So ..

Sub SettleAutoDue()

If WorksheetFunction.Count(Range("T4:T53")) <> 0 Then
Worksheets("A-3").Range("U4:Z4").Copy
Range("G5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Range("G4").Activate
End If

End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


Need help on this.

I don't want the Macro to work if [***IF COUNT(T4:T53) = 0 THEN EXIT SUB***]
inside the Macro below.


Sub SettleAutoDue()

***IF COUNT(T4:T53) = 0 THEN EXIT SUB***

Worksheets("A-3").Range("U4:Z4").Copy
Range("G5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Range("G4").Activate

End Sub


Thank you.
 
R

Roger Govier

Apologies, type too fast and missed the Range
If WorksheetFunction.Count(Range("T4:T53")) = 0 Then Exit Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top