Using variables within a formula in the same cell.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I make a formula with a variable (ex. 4+x), and make is so when I type
in a number into that cell it puts that number in as the variable? Is this
even possible? Thanks for your help in advance cause this problem has taken
way too much of my time already!
 
Not just 100% sure what you want to do. Are you wanting to put a formula in
Cell A1 such as =4+x and then in cell A1 type a 3 and heve the cell value
automatically be 7... or are you wanting something else entirely.
 
If?? you mean that you want to type in 1 and get 4, type in 2 and get 8 you
can do this with a worksheet_change event macro.
 
2 ways to do it... One is to use VBA and capture the cell change and apply
your formula through that or you can do it with a bit of hocus pocus using
the Camera tool. Here is a link to the Camera Tool thing.

http://j-walk.com/ss/excel/odd/odd04.htm

Place a formula on sheet 2 something to the effect of =Sheet1!A1 + 4
On sheet 1 format Cell A1 such that the font colour is the same as the
background colour (probably white). If you follow those steps from the web
site I posted you can make it work...
 
right click sheet tab>view code>insert this. Now if you put 1 in cell b1 you
get 5 in cell b1

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$1" Then Exit Sub
Application.EnableEvents = False
Target = Target + 4
Application.EnableEvents = True
End Sub
 
Back
Top