View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Cell displays formula instead of result

Just a try:

set the formats before putting the equation in
Range("E49").NumberFormat = "General", etc.
--
Gary's Student


"BAC" wrote:

Win 2000 Pro; Office 2003

I have a form where the user can enter either an "Equipment code" or an "ECI
Number". Since we do not know which one the user will have at the time he
completes the form, we have constructed a table that allows translation from
whichever one they enter to the one they don't have:

Col1: Col2: Col3:
Equip Code ECI Number Equip Code

I have a "Change event for the worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)
'On Error GoTo xitsub
Application.EnableEvents = False

Select Case Target.Address
Case Is = "$E$49"
'Entered an Equipment Code
Cells(50, "E").Formula = "=VLOOKUP(E49,Y2:Z54,2,FALSE)"

Case Is = "$E$50"
'Entered an ECI Number
Range("E49").Formula = "=VLOOKUP(E50,Z2:AA54,2,FALSE)"

Case Else
End Select

xitsub:
Application.EnableEvents = True
End Sub

This works fine except that the cell that has the formula inserted displays
the Formula as text rather than evaluating the formula to its appropriate
result.

I have the cell formats set as text because both values have leading zeros I
need to display.

I have tried the Range().FormulaRC format but that did the same thing.

What am I missing here?

Thanx

BAC