ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Selection < 0 then msgbox (https://www.excelbanter.com/excel-programming/427592-if-selection-0-then-msgbox.html)

Ron[_6_]

If Selection < 0 then msgbox
 
Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..

Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"

End If
End With

Assistance greatly appreciated, Ron

Simon Lloyd[_1112_]

If Selection < 0 then msgbox
 

Your just missing how to use a worksheet function in VBA:

Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With


Ron;324186 Wrote:
Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..

Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"

End If
End With

Assistance greatly appreciated, Ron



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Ron[_6_]

If Selection < 0 then msgbox
 
On Apr 27, 12:08*pm, Simon Lloyd
wrote:
Your just missing how to use a worksheet function in VBA:

Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With

Ron;324186 Wrote:

Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Hi Simon,
Thanks, this will come in handy in other projects. Thank you, Ron

Ron[_6_]

If Selection < 0 then msgbox
 
On Apr 27, 12:08*pm, Simon Lloyd
wrote:
Your just missing how to use a worksheet function in VBA:

Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With

Ron;324186 Wrote:

Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Is there a way to include the difference in the MsgBox?

Otto Moehrbach[_2_]

If Selection < 0 then msgbox
 
Something like this maybe:
MsgBox "Out of balance. Value is " & ActiveCell.Value & "."
HTH Otto
"Ron" wrote in message
...
On Apr 27, 12:08 pm, Simon Lloyd
wrote:
Your just missing how to use a worksheet function in VBA:

Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With

Ron;324186 Wrote:

Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's
Profile:http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Is there a way to include the difference in the MsgBox?



Ron[_6_]

If Selection < 0 then msgbox
 
On Apr 27, 1:42*pm, "Otto Moehrbach"
wrote:
Something like this maybe:
MsgBox "Out of balance. *Value is " & ActiveCell.Value & "."
HTH *Otto"Ron" wrote in message

...
On Apr 27, 12:08 pm, Simon Lloyd
wrote:





Your just missing how to use a worksheet function in VBA:


Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With


Ron;324186 Wrote:


Hello all,
I'm trying to validate that the total of the selected cell is < 0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd


Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's
Profile:http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Is there a way to include the difference in the MsgBox?- Hide quoted text -

- Show quoted text -


Hi Otto, since I'm working with a selection of cells could I edit
your solution? If I edit your solution to MsgBox "Out of balance.
Value is " & Selection.Value & "." will this work? Thank you, Ron

Simon Lloyd[_1114_]

If Selection < 0 then msgbox
 

Ron i think you may need this:


Dim SumRng as long
Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
SumRng= Application.WorksheetFunction.Sum(Selection)
if SumRng < 0 Then
MsgBox "Out of Balance, range value is " & SumRng
End If
End With


Ron;324548 Wrote:
On Apr 27, 1:42*pm, "Otto Moehrbach"
wrote:
Something like this maybe:
MsgBox "Out of balance. *Value is " & ActiveCell.Value & "."
HTH *Otto"Ron" wrote in message


...
On Apr 27, 12:08 pm, Simon Lloyd
wrote:





Your just missing how to use a worksheet function in VBA:


Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With


Ron;324186 Wrote:


Hello all,
I'm trying to validate that the total of the selected cell is <

0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd


Regards,
Simon Lloyd
'The Code Cage' ('The Code Cage' (http://www.thecodecage.com))

------------------------------------------------------------------------
Simon Lloyd's
Profile:'The Code Cage Forums - View Profile: Simon Lloyd'

(http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread:'If Selection < 0 then msgbox - The Code Cage

Forums' (http://www.thecodecage.com/forumz/sh...ad.php?t=90593)

Is there a way to include the difference in the MsgBox?- Hide quoted

text-

- Show quoted text -


Hi Otto, since I'm working with a selection of cells could I edit
your solution? If I edit your solution to MsgBox "Out of balance.
Value is " & Selection.Value & "." will this work? Thank you, Ron



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=90593


Ron[_6_]

If Selection < 0 then msgbox
 
On Apr 27, 11:16*pm, Simon Lloyd
wrote:
Ron i think you may need this:

Dim SumRng as long
Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
SumRng= Application.WorksheetFunction.Sum(Selection)
if SumRng < 0 Then
MsgBox "Out of Balance, range value is " & SumRng
End If
End With

Ron;324548 Wrote:





On Apr 27, 1:42*pm, "Otto Moehrbach"
wrote:
Something like this maybe:
MsgBox "Out of balance. *Value is " & ActiveCell.Value & "."
HTH *Otto"Ron" wrote in message


....
On Apr 27, 12:08 pm, Simon Lloyd
wrote:


Your just missing how to use a worksheet function in VBA:


Range(Selection, Selection.End(xlDown)).Offset(0,
11).Select
With Selection
If Application.WorksheetFunction.Sum(Selection) < 0 Then
MsgBox "Out of Balance"
End If
End With


Ron;324186 Wrote:


Hello all,
I'm trying to validate that the total of the selected cell is <

0
but, I'm getting an error with the code below..


Range(Selection, Selection.End(xlDown)).Offset(0, 11).Select
With Selection
If Sum.Selection < 0 Then
MsgBox "Out of Balance"


End If
End With


Assistance greatly appreciated, Ron


--
Simon Lloyd


Regards,
Simon Lloyd
'The Code Cage' ('The Code Cage' (http://www.thecodecage.com))


------------------------------------------------------------------------
Simon Lloyd's
Profile:'The Code Cage Forums - View Profile: Simon Lloyd'

(http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread:'If Selection < 0 then msgbox - The Code Cage

Forums' (http://www.thecodecage.com/forumz/sh...ad.php?t=90593)


Is there a way to include the difference in the MsgBox?- Hide quoted

text-


- Show quoted text -


Hi Otto, since I'm working with a selection of cells could I edit
your solution? If I edit your solution to MsgBox "Out of balance.
Value is " & Selection.Value & "." will this work? Thank you, Ron


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=90593- Hide quoted text -

- Show quoted text -


Simon, thanks. Exactly what I needed for this situation. Thank you
for your assistance, Ron

Simon Lloyd[_1116_]

If Selection < 0 then msgbox
 

Ron, thanks for joining our forum (The Code Cage), was your email
address right as the confirmation email has been returned?

Log on to the forum and send me a private message.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=90593



All times are GMT +1. The time now is 01:39 AM.

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