Consulting

Results 1 to 2 of 2

Thread: Write a value from a cell formula

  1. #1
    VBAX Regular
    Joined
    Sep 2007
    Posts
    6
    Location

    Question Write a value from a cell formula

    I need a macro to write the value 500 from A1 formula.

    For example:

    - If A1 fórmula is =R10, then macro should write value 500 in R10
    - If A1 fórmula is =J30, then macro should write value 500 in J30

    Is it possible to do this?

    Thanks a lot!

  2. #2
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    I cant for the life of me think why you would want to do that but:[VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1").HasFormula Then
    Range(Right(Range("A1").Formula, Len(Range("A1").Formula) - 1)) = 500
    End If
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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