![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Is there a way to use Events to enter a formula in Columm B when the use enters a value in Column A. How about deleting the formula if a value is deleted?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B" And Target.Value <> "" Then
Range("A1").Formula = "=B1"
ElseIf Target.Address = "$B" And Target.Value = "" Then
Range("A1").Formula = ""
End If
End Sub
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Al Chara,
Nothing happened? Remember, I need a formula inserted in Column B if a value is inputed in Column A. Also need to formula deleted if the value is deleted. Thanks! |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
I reversed it. Same code just replace all A's with B's and vice-versa
__________________
Kind regards, Al Chara |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
I did that, but nothing happened?
My sheet is protected though (Everthing except Column A), does that make a difference? |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
That would definitely make a difference. You cannot insert a formula into a locked cell on a protected sheet. Unlock cell B1 and it should work.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Al Chara,
Unprotected it and it still doesn't work. |
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
That is so odd, it seems that if I post the code in the BBcode option then it cuts off some text. I reversed it and didn't use BBcode. Man, that is weird. Should work now.
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" And Target.Value <> "" Then Range("B1").Formula = "=A1" ElseIf Target.Address = "$A$1" And Target.Value = "" Then Range("B1").Formula = "" End If End Sub
__________________
Kind regards, Al Chara |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|