#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Select Case

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select Case

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Select Case

Jim, that is close to what I need. I'm sorry for the thin description. I have
a sheet that is used to schedule employees. Col A is for names, B is for
start time, C is for end time and D is for hours worked. When someone is
scheduled for vacation, sick time, or a holiday I want to be able to enter
the appropriate letter in column B and have it return 8 (as in hours) for
that employee.

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Select Case

Can this be edited so that the Target is a range of cells rather than a column?

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Select Case

Remember, you're still changing the cell to the right

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub 'one cell at a time
If Intersect(Target, Me.Range("a1:a9,C3:c99,e14:e199,x5")) Is Nothing Then
Exit Sub
End If

Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select

End Sub


MikeG wrote:

Can this be edited so that the Target is a range of cells rather than a column?

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select Case

here it is for changed made to B2 through B100, updating column D... This
should be a bit closer...

Private Sub Worksheet_Change(ByVal Target As Range)
If not intersect (Target.Column, Range("B2:B100") is nothing Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 2).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub

--
HTH...

Jim Thomlinson


"MikeG" wrote:

Can this be edited so that the Target is a range of cells rather than a column?

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Select Case

I think that this:
If not intersect (Target.Column, Range("B2:B100") is nothing Then
should be:
If not intersect (Target, Range("B2:B100")) is nothing Then

Target.column will return a number (and a typo missing that final close
parenthesis).

Jim Thomlinson wrote:

here it is for changed made to B2 through B100, updating column D... This
should be a bit closer...

Private Sub Worksheet_Change(ByVal Target As Range)
If not intersect (Target.Column, Range("B2:B100") is nothing Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 2).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub

--
HTH...

Jim Thomlinson

"MikeG" wrote:

Can this be edited so that the Target is a range of cells rather than a column?

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select Case

Sure if you want the code to work you can do that but I thought that this was
much more inventive... ;-) Thanks for catching that one...
--
HTH...

Jim Thomlinson


"Dave Peterson" wrote:

I think that this:
If not intersect (Target.Column, Range("B2:B100") is nothing Then
should be:
If not intersect (Target, Range("B2:B100")) is nothing Then

Target.column will return a number (and a typo missing that final close
parenthesis).

Jim Thomlinson wrote:

here it is for changed made to B2 through B100, updating column D... This
should be a bit closer...

Private Sub Worksheet_Change(ByVal Target As Range)
If not intersect (Target.Column, Range("B2:B100") is nothing Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 2).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub

--
HTH...

Jim Thomlinson

"MikeG" wrote:

Can this be edited so that the Target is a range of cells rather than a column?

"Jim Thomlinson" wrote:

Your description is a little thin. Here is some event code that responds to
changes in column A and places a value beside the cell that was changed.
Right click the sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case UCase(Target.Value)
Case "A", "H", "V"
Target.Offset(0, 1).Value = 8
Case Else
MsgBox "Not A, H or V."
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Select Case

Are you required to use VBA?
Will cell validation work instead?

See http://www.contextures.com/xlDataVal01.html

Thx
MSweetG222



"MikeG" wrote:

I would like to be able to enter the letters "V", "H" or "A" into a cell and
have the number 8 entered into another cell. How can this be done using
Select Case?

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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case Jeff Excel Discussion (Misc queries) 1 February 27th 06 02:56 PM
Select Case help Ramthebuffs[_14_] Excel Programming 4 October 13th 05 12:41 AM
Select case Sandy[_6_] Excel Programming 2 July 3rd 05 09:23 PM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"