Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default adding a macro to a cell

Is there any way of changing this code so as to add the macro to more than
one cell?
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target = Range("$b$5") Then
With Target
Select Case .Value ' Assumes cell format is General
Case Is = 20
Call Macro1
Case Is = 30
Call Macro2
Case Is = 40
Call Macro3
Case Is = 45
Call Macro4
Case Is = 100
Call Macro5
Case Is = 800
Call Macro6
Case Is = 900
Call Macro7
Case Is = 950
Call Macro8
Case Is = 970
Call Macro9
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default adding a macro to a cell

Chang

If Target = Range("$b$5") Then

to

If Not Intersect(Target, Range("B5:K10")) Is Nothing Then


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"enyaw" wrote in message
...
Is there any way of changing this code so as to add the macro to more than
one cell?
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target = Range("$b$5") Then
With Target
Select Case .Value ' Assumes cell format is General
Case Is = 20
Call Macro1
Case Is = 30
Call Macro2
Case Is = 40
Call Macro3
Case Is = 45
Call Macro4
Case Is = 100
Call Macro5
Case Is = 800
Call Macro6
Case Is = 900
Call Macro7
Case Is = 950
Call Macro8
Case Is = 970
Call Macro9
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

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
Adding a Function to a cell when inserting a row from a macro Mbarnes Excel Worksheet Functions 0 May 31st 06 04:38 PM
adding cell data into a macro to allow specified information filte mattguerilla Excel Programming 3 May 24th 05 09:40 PM
adding a line at the end of a macro to name the cell yippy Excel Programming 2 January 3rd 04 02:15 AM
macro adding a number to a number already in a cell Don Guillett[_4_] Excel Programming 0 October 17th 03 05:21 PM
macro adding a number to a number already in a cell Ron de Bruin Excel Programming 0 October 17th 03 04:59 PM


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