ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Exit Sub if count less than zero. (https://www.excelbanter.com/excel-discussion-misc-queries/233404-exit-sub-if-count-less-than-zero.html)

[email protected]

Exit Sub if count less than zero.
 
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.

Mike H

Exit Sub if count less than zero.
 
try,

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

mike

" wrote:

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.


Jacob Skaria

Exit Sub if count less than zero.
 
Mark the code using a apostrophe in front; like

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


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


" wrote:

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.


Jacob Skaria

Exit Sub if count less than zero.
 
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


" wrote:

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.


Stan

Exit Sub if count less than zero.
 
It works. Thanks Mike.

"Mike H" wrote:

try,

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

mike

" wrote:

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.


Stan

Exit Sub if count less than zero.
 
It works. Thanks Jacob

"Jacob Skaria" wrote:

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


" wrote:

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.


Roger Govier[_3_]

Exit Sub if count less than zero.
 
Hi

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

--
Regards
Roger Govier

" wrote in
message ...
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.



Roger Govier[_3_]

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

--
Regards
Roger Govier

" wrote in
message ...
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.




All times are GMT +1. The time now is 10:47 PM.

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