Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default How to show a message box ?

Hi,
I would like a message box to display if the following conditions are met.
Assuming column A contains codes that do not change .

For example the code in column A6 is ADO and the value in G6 is less than
the value in H6 which is less than the value in K6. A message box comes up
with €śCode ADO has reached criteria€ť.

Being a complete newbie at VBA I would really appreciate some help.
Thankyou.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to show a message box ?

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

'If only in Row6
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A6,G6,H6,K6")) Is Nothing Then
If Range("A6") = "ADO" Then
If Range("G6") < Range("H6") And Range("H6") < Range("K6") Then
MsgBox "Code ADO has reached criteria"
End If
End If
End If
End Sub

'OR if you want this to work on all rows

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A" & Target.Row) = "ADO" Then
If Range("G" & Target.Row) < Range("H" & Target.Row) And _
Range("H" & Target.Row) < Range("K" & Target.Row) Then
MsgBox "Code ADO has reached criteria"
End If
End If
End Sub

--
Jacob


"Rob" wrote:

Hi,
I would like a message box to display if the following conditions are met.
Assuming column A contains codes that do not change .

For example the code in column A6 is ADO and the value in G6 is less than
the value in H6 which is less than the value in K6. A message box comes up
with €śCode ADO has reached criteria€ť.

Being a complete newbie at VBA I would really appreciate some help.
Thankyou.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How to show a message box ?

Hi Rob,

The code that Jacob posted will run whenever you make any change anywhere on
the worksheet. This code is restricted to run only when a change is made in
one of columns G, H or K. Therefore select the option that you prefer.

Copy the code below and then right click on the worksheet tab and select
View Code. Paste the code into the VBA editor. Cick on the cross with the
red background top right of VBA editor to close the VBA editor. Save the
workbook. You will also need to ensure that macros are enabled in Macro
security. See help for how to do this. (If using xl2007 then save as Macro
Enabled workbook.)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngIsect As Range
Dim lngRow As Long

Set rngIsect = Application.Intersect(Target, _
Union(Columns("G"), Columns("H"), Columns("K")))

If Not rngIsect Is Nothing Then
lngRow = Target.Row

If Range("G" & lngRow) < Range("H" & lngRow) And _
Range("H" & lngRow) < Range("K" & lngRow) Then

MsgBox "Code ADO has reached criteria"
End If

End If

End Sub

--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to show a message box ?

You can also amend the 1st option as below...

If Not Application.Intersect(Target, Range("A:A,G:G,H:H,K:K")) Is Nothing Then
If Range("A" & Target.Row) = "ADO" Then
If Range("G" & Target.Row) < Range("H" & Target.Row) And _
Range("H" & Target.Row) < Range("K" & Target.Row) Then
MsgBox "Code ADO has reached criteria"
End If
End If
End If

--
Jacob


"OssieMac" wrote:

Hi Rob,

The code that Jacob posted will run whenever you make any change anywhere on
the worksheet. This code is restricted to run only when a change is made in
one of columns G, H or K. Therefore select the option that you prefer.

Copy the code below and then right click on the worksheet tab and select
View Code. Paste the code into the VBA editor. Cick on the cross with the
red background top right of VBA editor to close the VBA editor. Save the
workbook. You will also need to ensure that macros are enabled in Macro
security. See help for how to do this. (If using xl2007 then save as Macro
Enabled workbook.)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngIsect As Range
Dim lngRow As Long

Set rngIsect = Application.Intersect(Target, _
Union(Columns("G"), Columns("H"), Columns("K")))

If Not rngIsect Is Nothing Then
lngRow = Target.Row

If Range("G" & lngRow) < Range("H" & lngRow) And _
Range("H" & lngRow) < Range("K" & lngRow) Then

MsgBox "Code ADO has reached criteria"
End If

End If

End Sub

--
Regards,

OssieMac


  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default How to show a message box ?

Thanks for your help Jacob.

"Jacob Skaria" wrote:

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

'If only in Row6
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A6,G6,H6,K6")) Is Nothing Then
If Range("A6") = "ADO" Then
If Range("G6") < Range("H6") And Range("H6") < Range("K6") Then
MsgBox "Code ADO has reached criteria"
End If
End If
End If
End Sub

'OR if you want this to work on all rows

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A" & Target.Row) = "ADO" Then
If Range("G" & Target.Row) < Range("H" & Target.Row) And _
Range("H" & Target.Row) < Range("K" & Target.Row) Then
MsgBox "Code ADO has reached criteria"
End If
End If
End Sub

--
Jacob


"Rob" wrote:

Hi,
I would like a message box to display if the following conditions are met.
Assuming column A contains codes that do not change .

For example the code in column A6 is ADO and the value in G6 is less than
the value in H6 which is less than the value in K6. A message box comes up
with €śCode ADO has reached criteria€ť.

Being a complete newbie at VBA I would really appreciate some help.
Thankyou.



  #6   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default How to show a message box ?

Thanks for your help OssieMac.

"OssieMac" wrote:

Hi Rob,

The code that Jacob posted will run whenever you make any change anywhere on
the worksheet. This code is restricted to run only when a change is made in
one of columns G, H or K. Therefore select the option that you prefer.

Copy the code below and then right click on the worksheet tab and select
View Code. Paste the code into the VBA editor. Cick on the cross with the
red background top right of VBA editor to close the VBA editor. Save the
workbook. You will also need to ensure that macros are enabled in Macro
security. See help for how to do this. (If using xl2007 then save as Macro
Enabled workbook.)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngIsect As Range
Dim lngRow As Long

Set rngIsect = Application.Intersect(Target, _
Union(Columns("G"), Columns("H"), Columns("K")))

If Not rngIsect Is Nothing Then
lngRow = Target.Row

If Range("G" & lngRow) < Range("H" & lngRow) And _
Range("H" & lngRow) < Range("K" & lngRow) Then

MsgBox "Code ADO has reached criteria"
End If

End If

End Sub

--
Regards,

OssieMac


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
show a message if print CC Excel Discussion (Misc queries) 2 February 17th 10 10:05 AM
Do not show this message again Tendresse Excel Programming 1 December 28th 08 11:04 AM
Cannot get message box to show Steven Excel Programming 1 July 4th 08 05:26 AM
message box does not show Marilyn Excel Discussion (Misc queries) 2 May 15th 08 11:44 PM
show message Mark Kubicki Excel Programming 6 December 19th 03 01:54 PM


All times are GMT +1. The time now is 11:09 PM.

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"