I would like to know how to have a letter generate a number when placed in a
cell randomly on a spreadsheet. For example anytime a P is placed in a cell
it would automatically equal 8
Thank You for your assistance.Bill Fitzgerald
=LOOKUP(C1,A1:B7,B1:B7)
C1 is the criteria
column A
a
b
c
d
e
f
g
column B
1
2
3
4
5
6
7
adjust the range and values to what you require--
davesexcel------------------------------------------------------------------------
davesexcel's Profile: www.excelforum.com/member.php...oamp;userid=31708
View this thread: www.excelforum.com/showthread...hreadid=536254Hi Bill,
If you want a quot;Pquot; that has been entered into any cell to automatically
convert to an quot;8quot; in that same cell then you would probably have to use
a Worksheet_Change Event Procedure in that worksheet's code module.
This example changes quot;pquot; or quot;Pquot; to 8 and quot;lquot; or quot;Lquot; to 12.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo ERRORHANDLER
Select Case UCase(Target.Value)
Case quot;Pquot;
Target.Value = 8
Case quot;Lquot;
Target.Value = 12
End Select
Application.EnableEvents = True
Exit Sub
ERRORHANDLER: Application.EnableEvents = True
End SubAdjust the code to suit your needs just by adding more (or deleting)
pairs of lines such as..
Case quot;some other letterquot;
Target.Value = some other number
If case sensitivity is needed then change...
Select Case UCase(Target.Value)
to...
Select Case Target.Value
and use the appropriate letter case in the Case statement
(Case quot;Pquot; or Case quot;pquot;)
To get the code in place...
1.Copy it
2. Right click the worksheet's tab.
3. Choose quot;View codequot; from the popup
4. Paste the code
The workbook now has a macro so Toolsgt;Macrogt;Securitygt;Medium.
Next time the book is opened click on Enable Macros on the Security
Warning dialog.
Ken Johnson
- Oct 05 Fri 2007 20:39
A letter to generat a number when entered into anywhere on the spr
close
全站熱搜
留言列表
發表留言