Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Event Macro?

I need help with a macro that will automatically run if
values in range D26:D29 have been added or changed.

Any help would be great,
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Event Macro?

Hi Lisa

You need a event

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm

For example

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D26:D29 "), Target) Is Nothing Then
MsgBox "You changed a cell in D26:D29 "
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in message ...
I need help with a macro that will automatically run if
values in range D26:D29 have been added or changed.

Any help would be great,
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Event Macro?

Works nicely, but when I right click the range and clear
contents, the spreadsheet freezes up on me.

Is there anyway to prevent this?

-----Original Message-----
Hi Lisa

You need a event

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm

For example

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D26:D29 "),

Target) Is Nothing Then
MsgBox "You changed a cell in D26:D29 "
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in

message ...
I need help with a macro that will automatically run if
values in range D26:D29 have been added or changed.

Any help would be great,
Thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Event Macro?

Yes

I forgot this first line
If Target.Cells.Count 1 Then Exit Sub

It only run if you change one cell in the range


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in message ...
Works nicely, but when I right click the range and clear
contents, the spreadsheet freezes up on me.

Is there anyway to prevent this?

-----Original Message-----
Hi Lisa

You need a event

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm

For example

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D26:D29 "),

Target) Is Nothing Then
MsgBox "You changed a cell in D26:D29 "
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in

message ...
I need help with a macro that will automatically run if
values in range D26:D29 have been added or changed.

Any help would be great,
Thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Event Macro?

Sorry, I forgot to add that this code will be calling
another macro. The following is the code that you gave me,
slightly modified a bit to call my macro, and the code
below that is the macro that is being called, what's weird
is that it works fine when using the worksheet change
macro for the pop up message, even when the cell is
cleared, but for some reason when I use it to call this
macro it works too, but freezes up when I right click a
cell and select clear contents.

Any more help would be greatly appreciated, Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Application.Intersect(Range("D26:D29 "),
Target) Is Nothing Then
Application.Run "'speedometer chart.xls'!
Chart_2049_Performance"
End If
End Sub



Sub Chart_2049_Performance()
Application.ScreenUpdating = False
Sheets("internal process perspective").Select
If Range("D26") = "" Then
Dim myChartObject As ChartObject
Dim myShape As Shape

With ActiveSheet
Set myChartObject = .ChartObjects("chart 2049")
For Each myShape In myChartObject.Chart.Shapes
If myShape.Type = msoPicture Then
'for testing:
'MsgBox myShape.Name
myShape.Delete
'just delete the first one found.
'exit for
End If
Next myShape
End With
ElseIf [D26] < "" Then
Application.Run "'speedometer chart.xls'!macro3"
End If
If Range("D27") < "" Then
Application.Run "'speedometer chart.xls'!macro4"
End If
If Range("D28") < "" Then
Application.Run "'speedometer chart.xls'!macro5"
End If
If Range("D29") < "" Then
Application.Run "'speedometer chart.xls'!macro6"
End If
End Sub

Sub macro3()
Application.ScreenUpdating = False
If Range("D26") Range("D25") Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Up_Picture_On_Chart2049"
ElseIf Range("D26") < Range("D25") Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Down_Picture_On_Chart2049"
End If

End Sub
Sub macro4()
Application.ScreenUpdating = False
If Range("D27") Range("D26") Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Up_Picture_On_Chart2049"
ElseIf [D27] < [D26] Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Down_Picture_On_Chart2049"
End If

End Sub

Sub macro5()
Application.ScreenUpdating = False
If Range("D28") Range("D27") Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Up_Picture_On_Chart2049"
ElseIf [D28] < [D27] Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Down_Picture_On_Chart2049"
End If

End Sub
Sub macro6()
Application.ScreenUpdating = False
If Range("D29") Range("D28") Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Up_Picture_On_Chart2049"
ElseIf [D29] < [D28] Then
Application.Run "'speedometer chart.xls'!
Delete_Airplane_Picture_Chart2049"
Application.Run "'speedometer chart.xls'!
Airplane_Down_Picture_On_Chart2049"
End If

End Sub


-----Original Message-----
Yes

I forgot this first line
If Target.Cells.Count 1 Then Exit Sub

It only run if you change one cell in the range


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in

message ...
Works nicely, but when I right click the range and clear
contents, the spreadsheet freezes up on me.

Is there anyway to prevent this?

-----Original Message-----
Hi Lisa

You need a event

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm

For example

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("D26:D29 "),

Target) Is Nothing Then
MsgBox "You changed a cell in D26:D29 "
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lisa" wrote in

message ...
I need help with a macro that will automatically run

if
values in range D26:D29 have been added or changed.

Any help would be great,
Thanks


.



.

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
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
It seems to me that I need an event Macro, nick s Excel Worksheet Functions 8 November 28th 05 05:37 PM
'Event' macro George Gee New Users to Excel 18 August 27th 05 12:50 PM
Event Macro Amy Excel Programming 2 August 4th 04 04:55 PM
Event macro? Kent Excel Programming 5 June 15th 04 02:54 AM


All times are GMT +1. The time now is 05:53 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"