Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Run a Macro

Hi, I'm hoping that someone will take a look at this for me....

I would like this macro to auto run whenever there is a change to the
contents of the cells within the given range. The range comprises the linked
cells from drop down boxes and are alphanumeric lables (if that makes a
difference)

The code which I have assembled from loads of posts on this site is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$AA$11:$AA$16" Then
Call ConfirmSelection
End If
End Sub

Sub ConfirmSelection()
Dim Msg As String
Select Case Range("AB16").Value = "5.5" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 7.1
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.7" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 8.8
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.8" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 10.6
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "8" And _
Range("AB15").Value = 7.8 And Range("AB15").Value <= 14.3
Case True
Msg = "OK"
Case Else
Msg = "Not OK, Please Re-select"
End Select
End Select
End Select
End Select
MsgBox "Indoor/Outdoor Unit Selection " & "" & Msg
End Sub


When I activate the code manually it works perfectly, but I just can't get
it work automatically.

Really hoping that someone can help.

Thanks

Anne

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Auto Run a Macro

On Jul 30, 10:02 am, AMell wrote:
Hi, I'm hoping that someone will take a look at this for me....

I would like this macro to auto run whenever there is a change to the
contents of the cells within the given range. The range comprises the linked
cells from drop down boxes and are alphanumeric lables (if that makes a
difference)

The code which I have assembled from loads of posts on this site is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$AA$11:$AA$16" Then
Call ConfirmSelection
End If
End Sub

Sub ConfirmSelection()
Dim Msg As String
Select Case Range("AB16").Value = "5.5" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 7.1
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.7" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 8.8
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.8" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 10.6
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "8" And _
Range("AB15").Value = 7.8 And Range("AB15").Value <= 14.3
Case True
Msg = "OK"
Case Else
Msg = "Not OK, Please Re-select"
End Select
End Select
End Select
End Select
MsgBox "Indoor/Outdoor Unit Selection " & "" & Msg
End Sub

When I activate the code manually it works perfectly, but I just can't get
it work automatically.

Really hoping that someone can help.

Thanks

Anne


This code is similar to what you want, it actually capitalizes text
when it's entered on a given range, in this case A1:A10.
If you follow it through, you should be able to adjust for what you're
doing.
Hope it helps

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then
Exit Sub
End If
On Error GoTo ErrHandler:
If Not Application.Intersect(Me.Range("A1:A10"), Target) Is
Nothing Then
If IsNumeric(Target.Value) = False Then
Application.EnableEvents = False
'Target.Value = StrConv(Target.Text, vbLowerCase)
Target.Value = StrConv(Target.Text, vbUpperCase)
'Target.Value = StrConv(Target.Text, vbProperCase)
Application.EnableEvents = True
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Run a Macro

Thanks for your assistance with this. I'm going to try to adapt your code to
do what I need it to do.

Anne

"Limey" wrote:

On Jul 30, 10:02 am, AMell wrote:
Hi, I'm hoping that someone will take a look at this for me....

I would like this macro to auto run whenever there is a change to the
contents of the cells within the given range. The range comprises the linked
cells from drop down boxes and are alphanumeric lables (if that makes a
difference)

The code which I have assembled from loads of posts on this site is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$AA$11:$AA$16" Then
Call ConfirmSelection
End If
End Sub

Sub ConfirmSelection()
Dim Msg As String
Select Case Range("AB16").Value = "5.5" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 7.1
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.7" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 8.8
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "6.8" And _
Range("AB15").Value = 4 And Range("AB15").Value <= 10.6
Case True
Msg = "OK"
Case Else
Select Case Range("AB16").Value = "8" And _
Range("AB15").Value = 7.8 And Range("AB15").Value <= 14.3
Case True
Msg = "OK"
Case Else
Msg = "Not OK, Please Re-select"
End Select
End Select
End Select
End Select
MsgBox "Indoor/Outdoor Unit Selection " & "" & Msg
End Sub

When I activate the code manually it works perfectly, but I just can't get
it work automatically.

Really hoping that someone can help.

Thanks

Anne


This code is similar to what you want, it actually capitalizes text
when it's entered on a given range, in this case A1:A10.
If you follow it through, you should be able to adjust for what you're
doing.
Hope it helps

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then
Exit Sub
End If
On Error GoTo ErrHandler:
If Not Application.Intersect(Me.Range("A1:A10"), Target) Is
Nothing Then
If IsNumeric(Target.Value) = False Then
Application.EnableEvents = False
'Target.Value = StrConv(Target.Text, vbLowerCase)
Target.Value = StrConv(Target.Text, vbUpperCase)
'Target.Value = StrConv(Target.Text, vbProperCase)
Application.EnableEvents = True
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub


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
Auto run macro Esradekan Excel Worksheet Functions 5 August 31st 08 11:58 PM
Auto run macro March Excel Discussion (Misc queries) 10 January 17th 08 08:16 PM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Auto-run macro after auto-query refresh (Excel2000,sr1) Bill Cufflin Excel Programming 3 June 29th 06 03:30 AM


All times are GMT +1. The time now is 12:00 AM.

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"