Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can I make an error message pop up for a user?


I have a sheet with a list of employees that has percentages listed in 4
columns out from their name. How can I get an error message to pop up for
any row that doesn't equal 100% when you add up the 4 columns in each row?
Therefore, I want the macro to loop around so that it goes down the sheet
summing the 4 columns for each employee and an error message will pop when it
hits a row that doesn't equal 100%.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default How can I make an error message pop up for a user?


Something like this should do the job:

Sub test()

Dim i As Long
Dim LR As Long
Dim arr

LR = Cells(65536, 1).End(xlUp).Row

arr = Range(Cells(1), Cells(LR, 4))

For i = 1 To UBound(arr)
If arr(i, 1) + arr(i, 2) + arr(i, 3) + arr(i, 4) < 1 Then
Range(Cells(i, 1), Cells(i, 4)).Select
MsgBox "row " & i & " (the selected range) does not add up to 100%!",
_
vbCritical, "checking row sums"
End If
Next i

End Sub


RBS


"Can't do Macros" <Can't do wrote in
message ...
I have a sheet with a list of employees that has percentages listed in 4
columns out from their name. How can I get an error message to pop up for
any row that doesn't equal 100% when you add up the 4 columns in each row?
Therefore, I want the macro to loop around so that it goes down the sheet
summing the 4 columns for each employee and an error message will pop when
it
hits a row that doesn't equal 100%.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can I make an error message pop up for a user?


Thanks for your help. I entered the code you gave me, but I get an error
message for the line that says vbCritical, "checking row sums"
The error message I get is: Compile error: Invalid use of property.

Do you have any tips for getting rid of this error message?

Thanks again!

"RB Smissaert" wrote:

Something like this should do the job:

Sub test()

Dim i As Long
Dim LR As Long
Dim arr

LR = Cells(65536, 1).End(xlUp).Row

arr = Range(Cells(1), Cells(LR, 4))

For i = 1 To UBound(arr)
If arr(i, 1) + arr(i, 2) + arr(i, 3) + arr(i, 4) < 1 Then
Range(Cells(i, 1), Cells(i, 4)).Select
MsgBox "row " & i & " (the selected range) does not add up to 100%!",
_
vbCritical, "checking row sums"
End If
Next i

End Sub


RBS


"Can't do Macros" <Can't do wrote in
message ...
I have a sheet with a list of employees that has percentages listed in 4
columns out from their name. How can I get an error message to pop up for
any row that doesn't equal 100% when you add up the 4 columns in each row?
Therefore, I want the macro to loop around so that it goes down the sheet
summing the 4 columns for each employee and an error message will pop when
it
hits a row that doesn't equal 100%.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default How can I make an error message pop up for a user?


Probably the linebreaks messing things up.
Put your cursor after:
100%!",
and press the Dell key a few times till you got vbCritical right after the
above.
Then try again.

RBS


"Can''t do Macros" wrote in message
...
Thanks for your help. I entered the code you gave me, but I get an error
message for the line that says vbCritical, "checking row sums"
The error message I get is: Compile error: Invalid use of property.

Do you have any tips for getting rid of this error message?

Thanks again!

"RB Smissaert" wrote:

Something like this should do the job:

Sub test()

Dim i As Long
Dim LR As Long
Dim arr

LR = Cells(65536, 1).End(xlUp).Row

arr = Range(Cells(1), Cells(LR, 4))

For i = 1 To UBound(arr)
If arr(i, 1) + arr(i, 2) + arr(i, 3) + arr(i, 4) < 1 Then
Range(Cells(i, 1), Cells(i, 4)).Select
MsgBox "row " & i & " (the selected range) does not add up to
100%!",
_
vbCritical, "checking row sums"
End If
Next i

End Sub


RBS


"Can't do Macros" <Can't do wrote in
message ...
I have a sheet with a list of employees that has percentages listed in 4
columns out from their name. How can I get an error message to pop up
for
any row that doesn't equal 100% when you add up the 4 columns in each
row?
Therefore, I want the macro to loop around so that it goes down the
sheet
summing the 4 columns for each employee and an error message will pop
when
it
hits a row that doesn't equal 100%.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Message if user leaves a field blank GillianX Excel Worksheet Functions 1 October 14th 08 05:40 PM
VBA help - error message to user [email protected][_2_] Excel Programming 3 May 15th 07 10:28 PM
User Defined Functions - Help Text - Make it Easy for the User Andibevan[_2_] Excel Programming 4 March 17th 05 09:51 AM
Displaying a message in a message box without requiring user to click anything to proceed Android[_2_] Excel Programming 2 June 25th 04 06:44 PM
Asking user to print and error message Olly[_3_] Excel Programming 1 November 17th 03 01:18 PM


All times are GMT +1. The time now is 06:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"