Consulting

Results 1 to 4 of 4

Thread: Refer to range in cell formula

  1. #1
    VBAX Newbie
    Joined
    Nov 2019
    Posts
    2
    Location

    Refer to range in cell formula

    Hi all,

    Can someone help me with this vba code in excel? It errors but I Can’t figure out why. I want to write a cell formula with a dynamic range. Therefore, I specify this range in the vba code, but it errors every time. Does anyone know how to solve this?

    Dim rng1 As Range

    Set rng1 = Sheets("Product KG").ListObjects("Table5").ListColumns(41).DataBodyRange

    Sheets("Product KG").Activate
    Range("AV7").Select
    Selection.FormulaArray = _
    "=LARGE((ROUND(" & rng1 & ",2)+ROW(" & rng1 & ")/10000),RC[-5])"

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Not tested but try (change Column41 to the header of the column):
    Range("AV7").FormulaArray = _"=LARGE((ROUND(Table5[Column41],2)+ROW(Table5[Column41])/10000),RC[-5])"
    Semper in excretia sumus; solum profundum variat.

  3. #3
    VBAX Newbie
    Joined
    Nov 2019
    Posts
    2
    Location
    Yes it works, thank you!

  4. #4
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    You're welcome , you can mark it Solved (Thread Tools, top right).
    Semper in excretia sumus; solum profundum variat.

Tags for this Thread

Posting Permissions

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