Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Message Box should Popup on condition

A B C…..col
Car** 37 100
Van**
Bike 60
Plan** 3
Train

Hi all, I have above data in Sheet1. In above data in cell "C1" I
have fromula "=SUM(B1:B5)" which actually shows total of figures in
column B. I want some macro in Worksheet module which show a Message
Box only if cell "C1" have total amount 100 and if there is any figure
or amount been put by user in column B cell which is next to the text
of column A got ** in the end. For example looking at above data
there are amounts next to the text "Car**" and "Plan**" and as these
text got "**" in the end and total in cell "C1" is also 100 so message
box should pop up saying

As you have put amount next to the:
Car**
Plan**
Please go to Sheet2

and as soon as user click on "OK" on Message Box macro should select
Sheet2
Please can any friend help me on this
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Message Box should Popup on condition

right-click on the sheet tab and select 'View Code' then paste this:

Option Explicit
Private Sub Worksheet_Calculate()
If Range("C1").Value = 100 Then
checkRangeB1_B5
End If
End Sub
Sub checkRangeB1_B5()
Dim cell As Range
Dim text As String
For Each cell In Range("A1:A5").Cells
If Right(cell.Value, 2) = "**" Then
If Not (IsEmpty(cell.Offset(, 1))) Then
text = text & vbCrLf & cell.Value
End If
End If
Next
If text = "" Then Exit Sub
text = "As you have put amount next to the:" & vbCrLf & Mid(text, 2)
MsgBox text
Worksheets("Sheet2").Activate
End Sub


This uses the cheet's 'Calculate' event. When any cell is calculated on the
sheet, this event will fire. First we check if the value in C1 is equal to
100, and if it is we proceed to check cells B1-B5
If any cells have a value, and the cell in the correspondin row column A
ends with **, then a message is displayed and sheet2 activated as requested.





"K" wrote:

A B C€¦..col
Car** 37 100
Van**
Bike 60
Plan** 3
Train

Hi all, I have above data in Sheet1. In above data in cell "C1" I
have fromula "=SUM(B1:B5)" which actually shows total of figures in
column B. I want some macro in Worksheet module which show a Message
Box only if cell "C1" have total amount 100 and if there is any figure
or amount been put by user in column B cell which is next to the text
of column A got ** in the end. For example looking at above data
there are amounts next to the text "Car**" and "Plan**" and as these
text got "**" in the end and total in cell "C1" is also 100 so message
box should pop up saying

As you have put amount next to the:
Car**
Plan**
Please go to Sheet2

and as soon as user click on "OK" on Message Box macro should select
Sheet2
Please can any friend help me on this

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 174
Default Message Box should Popup on condition

Hi K,

Open VBE <Alt<F11, double click on sheet1 and paste following code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim strMsg As String
strMsg = "As you have amount next to the:" & vbCr

If Target.Column = 2 Then
If Range("C1") = 100 Then
If Range("B1") 0 Then strMsg = strMsg & "Car**" & vbCr
If Range("B2") 0 Then strMsg = strMsg & "Van**" & vbCr
If Range("B4") 0 Then strMsg = strMsg & "Plan**" & vbCr

strMsg = strMsg & "Please go to Sheet2"
MsgBox Prompt:=strMsg, Buttons:=vbOKOnly, Title:="aaa"
Sheets("Sheet2").Activate
End If
End If
End Sub

This code is not checking "**", so you cannot change the order in A1. So you
might need to add additional checks.
(to check on "**" you can use instr ...

if instr(1, range("A1"), "**",vbtextcompare)0 and range("A1").offset(0,1)0
then styrmsg =strmsg & range("A1") & vbcr

Wkr,

JP

"K" wrote in message
...
A B C…..col
Car** 37 100
Van**
Bike 60
Plan** 3
Train

Hi all, I have above data in Sheet1. In above data in cell "C1" I
have fromula "=SUM(B1:B5)" which actually shows total of figures in
column B. I want some macro in Worksheet module which show a Message
Box only if cell "C1" have total amount 100 and if there is any figure
or amount been put by user in column B cell which is next to the text
of column A got ** in the end. For example looking at above data
there are amounts next to the text "Car**" and "Plan**" and as these
text got "**" in the end and total in cell "C1" is also 100 so message
box should pop up saying

As you have put amount next to the:
Car**
Plan**
Please go to Sheet2

and as soon as user click on "OK" on Message Box macro should select
Sheet2
Please can any friend help me on this


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Message Box should Popup on condition

thanks guys for your help. its fantastic

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
Popup-Message when using UDF from add-In [email protected] Excel Programming 0 April 17th 08 12:32 PM
popup message KYaeger Excel Programming 1 February 27th 07 02:44 AM
Popup Comment Box if a Certain Condition is Met [email protected] Excel Programming 2 September 20th 06 01:53 AM
Message popup bbc1 Excel Discussion (Misc queries) 7 August 15th 05 03:29 PM
Popup message Todd Huttenstine[_2_] Excel Programming 2 November 14th 03 08:45 PM


All times are GMT +1. The time now is 03:38 AM.

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

About Us

"It's about Microsoft Excel"