Consulting

Results 1 to 4 of 4

Thread: VBA to use Selection.Address in a formula

  1. #1
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location

    VBA to use Selection.Address in a formula

    I have this bit of code
    Range("H" & iRow).Resize(cRng, 12).Select
    addr = Selection.Address
    I am trying to get this formula into a cell using VBA
    =ColorFunction($IE$1,$H2:$S3,TRUE)

    So that it says

    ActiveSheet.Range("IG2").Formula = "=ColorFunction($IE$1,$H2:$S3,TRUE)”
    $ID$1, $IE$1, $IF$1 is from the color that we’re looking for.
    I may put the selected value into a variable.
    addr is $H2:$S3 BUT $H2:$S3 is also located in cell HY1

    How do I code this "=ColorFunction($IE$1 ,addr,TRUE)”

  2. #2
    =ColorFunction($IE$1 ," & addr & ",TRUE)”

  3. #3
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location
    ..

  4. #4
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location
    arnelgp: Thanks.
    It works.

          addr = Selection.Address
          ActiveSheet.Range("IG2").Formula = "=ColorFunction($IE$1 ," & addr & ",TRUE)"

Posting Permissions

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