Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Dana,
Very cool! I understand the code, but I'm curious to understand the thought process (backwards reasoning?) that got you there. I don't really see any relationship between these letters and numbers. I also tweaked my code a little so that it handles ranges of more than one cell. Also, if a cell with one of the 4 values is cleared or changed the corresponding numbers are cleared: Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Dim c As Range For Each c In Target If c.Column = 3 Then Set rng = c.Offset(0, 1) Select Case c Case "E", "L", "K", "Q" rng = (23447120 Mod (Asc(c) + 10)) / 10 Case Else rng.Clear End Select End If Next c End Sub Doug "Dana DeLouis" wrote in message ... I was experimenting with something related. Just something different... Select Case Target Case "E", "L", "K", "Q" rng = (23447120 Mod (Asc(Target) + 10)) / 10 Case Else ' ?? -- Dana DeLouis Using Windows XP & Office XP = = = = = = = = = = = = = = = = = "Doug Glancy" wrote in message ... For a non-programming alternative you could take a look at the Vlookup function. Using it you could create a simple lookup table that will do what you want. For a VBA solution, paste the following into the code module for the worksheet (right-click the sheet tab, choose View Code and paste it there): Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range If Target.Column = 3 Then Set r = Target.Offset(0, 1) Select Case Target Case "E" r = 7.8 Case "L" r = 8 Case "K" r = 4 Case "Q" r = 6 End Select End If End Sub hth, Doug <snip |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Import New Database Query (Union Query) in Spreadsheet | Excel Discussion (Misc queries) | |||
Use MS Query to query data within the current work book | Excel Discussion (Misc queries) | |||
Convert hard coded query criteria to Parameter Query | Excel Discussion (Misc queries) | |||
Excel 2007 / MS Query - editing existing query to another sheet | Excel Discussion (Misc queries) | |||
Save data retreived from query without saving query | Excel Discussion (Misc queries) |