Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Returning contents of another cell using VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Returning contents of another cell using VBA

    I'm trying to figure out how the return the contents of another cell. For example, I want cell B2 to reflect the contents of cell A1 such that if the spreadsheet user changes the contents of cell A1, it show up in B2 as well, and I need to set this up using VBA.

    In excel, if I type "=A1" into cell B2, then whenever the contents of cell A1 is changed by the spreadsheet user, the contents of cell B2 automatically changes as well without running my VBA macro again.

    Using VBA, if I do: cell(B2) = cell(A1)
    cell B2 contains the contents of cell A1, but if the user changes the contents of cell A1, cell B2 does not update to reflect that automatically.

    Thanks for any help you can offer,
    Steve

  • #2
    Re: Returning contents of another cell using VBA

    Use the worksheet change event in the sheet so
    Code:
    if target.address = "$A$2" then
    Range("b2").value = Range("a2").value
    end if

    Comment


    • #3
      Re: Returning contents of another cell using VBA

      Thanks, I wasn't familiar with worksheet change events, but I read up on it and think that will do I need. Thanks very much for your help.

      Comment

      Trending

      Collapse

      There are no results that meet this criteria.

      Working...
      X