Thread: Multiple IFs
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Multiple IFs

Hi Phil,

I have roughly 100 values I need to format cells with using the if
function. Is this possible? I need the cell to display each 'if' value
when the relevant figure is inserted.


Try something like:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim rcell As Range
Const sAdd As String = "A1:A10"

Set rng = Intersect(Range(sAdd), Target)

For Each rcell In rng.Cells
With rcell
Select Case .Value
Case 1: .Value = "Anne"
Case 2: .Value = "Ben"
Case 3: .Value = "Carol"

'................
'................
Case 100: .Value = "Xavier"
End Select
End With
Next rcell
End Sub

'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman