Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default Running macro depending on cell value

I want to run a macro depending on the cell value, selected from a
drop down box.

Lets say that data to select from is numbers 1 - 20
Lets say I wish to take the person from Sheets 1 - 20 accordingly


How can I do that


TIA


Esra
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Running macro depending on cell value

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "G1" '<== change to suit
Dim cell As Range

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
On Error Resume Next
Worksheets("Sheet" & .Value).Activate
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Esradekan" wrote in message
...
I want to run a macro depending on the cell value, selected from a
drop down box.

Lets say that data to select from is numbers 1 - 20
Lets say I wish to take the person from Sheets 1 - 20 accordingly


How can I do that


TIA


Esra



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default Running macro depending on cell value

On Jan 29, 12:27*pm, "Bob Phillips" wrote:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "G1" * * '<== change to suit
Dim cell As Range

* * On Error GoTo ws_exit
* * Application.EnableEvents = False

* * If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
* * * * With Target
* * * * * * On Error Resume Next
* * * * * * Worksheets("Sheet" & .Value).Activate
* * * * End With
* * End If

ws_exit:
* * Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Esradekan" wrote in message

...



I want to run a macro depending on the cell value, selected from a
drop down box.


Lets say that data to select from is numbers 1 - 20
Lets say I wish to take the person from Sheets 1 - 20 accordingly


How can I do that


TIA


Esra- Hide quoted text -


- Show quoted text -


I dont understand this, but its ok, I have done it another way.

Thank you for your help. I appreciate it.

Esra
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
Running Macro when a cell value changes Ayo Excel Discussion (Misc queries) 1 April 18th 07 03:09 PM
Running a macro on cell value change Brettjg Excel Discussion (Misc queries) 2 March 28th 07 02:55 PM
Running a macro on cell value change Mike Excel Discussion (Misc queries) 0 March 28th 07 01:13 AM
Macro to coppy cells to certain rows depending on value in cell Esrei Excel Discussion (Misc queries) 0 December 9th 05 07:57 AM
Macro running when a cell is exited Daniel Lees Excel Discussion (Misc queries) 1 July 20th 05 02:45 PM


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