View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Howard Silcock Howard Silcock is offline
external usenet poster
 
Posts: 16
Default can a cell be both input and output?

On Friday, 15 November 2013 04:12:01 UTC+11, Claus Busch wrote:
Hi Bob,



Am Thu, 14 Nov 2013 09:02:03 -0800 schrieb bob:



let's call cell A1 "inches", and B1 "cm"




if the user enters a number in A1 (then hit tab or enter), the equivalent


length in cm will be displayed in B1




if the user enters a number in B1, the equivalent length in inches will be


displayed in A1




that is possible using VBA. Right click on sheet tab = Show code =

Paste following code into the code module of the worksheet:



Private Sub Worksheet_Change(ByVal Target As Range)



Select Case Target.Address(0, 0)

Case "A1"

Range("B1") = 2.54 * Target

Case "B1"

Range("A1") = Target / 2.54

End Select

End Sub





Regards

Claus B.

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2


This is really neat. I have often wanted to do this kind of thing but it seemed to be "obviously impossible", so I never even explored the options.

Howard