#1   Report Post  
bart
 
Posts: n/a
Default number to name

I want to do my schedule with Excell, and I was wondering if it's possible to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark. is
there a way that if I type "1" under the 3rd of february, that converts it
directly to Mark?
thanks
Gaetan
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's possible

to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark. is
there a way that if I type "1" under the 3rd of february, that converts it
directly to Mark?
thanks
Gaetan



  #3   Report Post  
Jim May
 
Posts: n/a
Default

Bob,
Side question..
I notice that
Application.EnableEvents = True << only appears under ws_exit:
and not elsewhere,
This says to me that ONLY if there is an error does the status of
EnableEvents
get "turned-back" to "On", or TRUE;
Is this because EnableEvents whenever set to False, defaults back to True on
successful
completion of any/all SUB(s)?
TIA,
Jim May


"Bob Phillips" wrote in message
...
Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's

possible
to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark. is
there a way that if I type "1" under the 3rd of february, that converts

it
directly to Mark?
thanks
Gaetan





  #4   Report Post  
JulieD
 
Posts: n/a
Default

Hi Jim

as Bob has not coded an "end sub" prior to the error handler, the code under
the error handler runs in all circumstances.

if you turn application.enableevents off you need to turn them back on as it
does not happen automatically ever.

Cheers
JulieD


"Jim May" wrote in message
news:xSMKd.53244$jn.37047@lakeread06...
Bob,
Side question..
I notice that
Application.EnableEvents = True << only appears under ws_exit:
and not elsewhere,
This says to me that ONLY if there is an error does the status of
EnableEvents
get "turned-back" to "On", or TRUE;
Is this because EnableEvents whenever set to False, defaults back to True
on
successful
completion of any/all SUB(s)?
TIA,
Jim May


"Bob Phillips" wrote in message
...
Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's

possible
to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark.
is
there a way that if I type "1" under the 3rd of february, that converts

it
directly to Mark?
thanks
Gaetan







  #5   Report Post  
Jim May
 
Posts: n/a
Default

Thanks for the clarification.
Jim

"JulieD" wrote in message
...
Hi Jim

as Bob has not coded an "end sub" prior to the error handler, the code

under
the error handler runs in all circumstances.

if you turn application.enableevents off you need to turn them back on as

it
does not happen automatically ever.

Cheers
JulieD


"Jim May" wrote in message
news:xSMKd.53244$jn.37047@lakeread06...
Bob,
Side question..
I notice that
Application.EnableEvents = True << only appears under ws_exit:
and not elsewhere,
This says to me that ONLY if there is an error does the status of
EnableEvents
get "turned-back" to "On", or TRUE;
Is this because EnableEvents whenever set to False, defaults back to

True
on
successful
completion of any/all SUB(s)?
TIA,
Jim May


"Bob Phillips" wrote in message
...
Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's

possible
to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark.
is
there a way that if I type "1" under the 3rd of february, that

converts
it
directly to Mark?
thanks
Gaetan










  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Jim,

To add a couple of points to Julie's response that may be helpful in general
understanding.

When code is executing, it always progresses to the next line unless there
is some statement that 'diverts' it, such as an If ... n/l ... statements
.... n/l ... Else ... etc, a loop construct (which sends it back), a function
or Sub call, or a Goto (sorry, bit basic, but I need to spell it out for the
rest :-)). My real point here is that a label does not divert the code, it
just gets passed over and ignored. The label only comes into play should
there be a Goto, and the code executes the Goto. So my code passes over the
label.

The purpose of that code is to ensure that events are always re-enabled,
whether an error is encountered or not. The answer to your second question
is most definitely not, exiting a sub does not re-enable events, you must do
so, or potentially create havoc.

As a side note, as I was writing the second paragraph above, I wondered
about Gosub. My old BBC Basic supported Gosub (in a similar manner to Call
in VBA), but I had never seen anyone use it in VBA. So I looked it up in
help, and VBA does support it. Look it up in help, it's weird, no wonder
no-one ever uses it.

Regards

Bob


"Jim May" wrote in message
news:waPKd.53265$jn.34763@lakeread06...
Thanks for the clarification.
Jim

"JulieD" wrote in message
...
Hi Jim

as Bob has not coded an "end sub" prior to the error handler, the code

under
the error handler runs in all circumstances.

if you turn application.enableevents off you need to turn them back on

as
it
does not happen automatically ever.

Cheers
JulieD


"Jim May" wrote in message
news:xSMKd.53244$jn.37047@lakeread06...
Bob,
Side question..
I notice that
Application.EnableEvents = True << only appears under ws_exit:
and not elsewhere,
This says to me that ONLY if there is an error does the status of
EnableEvents
get "turned-back" to "On", or TRUE;
Is this because EnableEvents whenever set to False, defaults back to

True
on
successful
completion of any/all SUB(s)?
TIA,
Jim May


"Bob Phillips" wrote in message
...
Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's
possible
to
type a number and get a name instead... for example if on the 3rd

of
february, Mark is working, and that I associate the number 1 to

Mark.
is
there a way that if I type "1" under the 3rd of february, that

converts
it
directly to Mark?
thanks
Gaetan










  #7   Report Post  
Jim May
 
Posts: n/a
Default

Tks Bob,
always appreciate your going the extra mile to offer
what doesn't get written ...
Jim


"Bob Phillips" wrote in message
...
Jim,

To add a couple of points to Julie's response that may be helpful in

general
understanding.

When code is executing, it always progresses to the next line unless there
is some statement that 'diverts' it, such as an If ... n/l ... statements
... n/l ... Else ... etc, a loop construct (which sends it back), a

function
or Sub call, or a Goto (sorry, bit basic, but I need to spell it out for

the
rest :-)). My real point here is that a label does not divert the code, it
just gets passed over and ignored. The label only comes into play should
there be a Goto, and the code executes the Goto. So my code passes over

the
label.

The purpose of that code is to ensure that events are always re-enabled,
whether an error is encountered or not. The answer to your second question
is most definitely not, exiting a sub does not re-enable events, you must

do
so, or potentially create havoc.

As a side note, as I was writing the second paragraph above, I wondered
about Gosub. My old BBC Basic supported Gosub (in a similar manner to Call
in VBA), but I had never seen anyone use it in VBA. So I looked it up in
help, and VBA does support it. Look it up in help, it's weird, no wonder
no-one ever uses it.

Regards

Bob


"Jim May" wrote in message
news:waPKd.53265$jn.34763@lakeread06...
Thanks for the clarification.
Jim

"JulieD" wrote in message
...
Hi Jim

as Bob has not coded an "end sub" prior to the error handler, the code

under
the error handler runs in all circumstances.

if you turn application.enableevents off you need to turn them back on

as
it
does not happen automatically ever.

Cheers
JulieD


"Jim May" wrote in message
news:xSMKd.53244$jn.37047@lakeread06...
Bob,
Side question..
I notice that
Application.EnableEvents = True << only appears under ws_exit:
and not elsewhere,
This says to me that ONLY if there is an error does the status of
EnableEvents
get "turned-back" to "On", or TRUE;
Is this because EnableEvents whenever set to False, defaults back to

True
on
successful
completion of any/all SUB(s)?
TIA,
Jim May


"Bob Phillips" wrote in message
...
Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's
possible
to
type a number and get a name instead... for example if on the 3rd

of
february, Mark is working, and that I associate the number 1 to

Mark.
is
there a way that if I type "1" under the 3rd of february, that

converts
it
directly to Mark?
thanks
Gaetan












  #8   Report Post  
bart
 
Posts: n/a
Default

Thanks a lot...it's working great... have a nice sunday...

"Bob Phillips" wrote:

Bart,

Using event code you can do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:H10")) Is Nothing Then
With Target
Select Case .Value
Case 1: .Value = "Mark"
Case 2: .Value = "John"
Case 3: .Value = "Bill"
End Select
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.

Extend the list as far as you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bart" wrote in message
...
I want to do my schedule with Excell, and I was wondering if it's possible

to
type a number and get a name instead... for example if on the 3rd of
february, Mark is working, and that I associate the number 1 to Mark. is
there a way that if I type "1" under the 3rd of february, that converts it
directly to Mark?
thanks
Gaetan




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
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
How to format a number in Indian style in Excel? Victor_alb Excel Discussion (Misc queries) 2 December 21st 04 04:21 AM
Defining a number in a cell by text then subtracting it by the tex Crowraine Excel Worksheet Functions 1 December 16th 04 07:49 AM
Formatting a cell as "text" in the number catagory. Ed Excel Worksheet Functions 3 December 7th 04 07:12 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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