Event to enter a formula in B1 once a Value is entered in A1
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Event to enter a formula in B1 once a Value is entered in A1

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I reversed it. Same code just replace all A's with B's and vice-versa
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I did that, but nothing happened?

    My sheet is protected though (Everthing except Column A), does that make a difference?

  6. #6
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  7. #7
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Al Chara,

    Unprotected it and it still doesn't work.

  8. #8
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com