+ Reply to Thread
Results 1 to 5 of 5

Absolute Reference While Using Cells Function

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Absolute Reference While Using Cells Function

    Good morning,

    Looking to use an absolute reference to lock certain cells into a sumif formula. Please see below for current code:

     Range(Cells(2, UpdatedLastCol + 4), Cells(LOBCount, UpdatedLastCol + 4)).Formula = "=SUMIF($" & Cells(2, LastCol + 3).Address(0, 0) & ":" & Cells(LastRow, LastCol + 3).Address(0, 0) & "," & Cells(2, UpdatedLastCol + 3).Address(0, 0) & ",$H$2:$" & Cells(LastRow, LastCol).Address(0, 0) & ")"
    I am needing to lock in the row numbers for the criteria and sum range. Any help is appreciated. Currently the above formula returns this within the spreadsheet:

    =SUMIF($P2:P3217,S2,$H$2:$M3217)

    I am needing it to be the following:

    =SUMIF($P$2:$P$3217,S2,$H$2:$M$3217)

    Thanks.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Absolute Reference While Using Cells Function

    Hi, zmster2033,

    maybe try
     Range(Cells(2, UpdatedLastCol + 4), Cells(LOBCount, UpdatedLastCol + 4)).Formula = "=SUMIF(" & Cells(2, LastCol + 3).Address & ":" & Cells(LastRow, LastCol + 3).Address & "," & Cells(2, UpdatedLastCol + 3).Address(0, 0) & ",$H$2:$" & Cells(LastRow, LastCol).Address & ")"
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Absolute Reference While Using Cells Function

    Hello Holger,

    Unfortunately that did not work. It gave me a Runtime 1004 error.

    Thanks.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Absolute Reference While Using Cells Function

    Hi, zmster2033,

    missed an additional $ you ghad set:
     Range(Cells(2, UpdatedLastCol + 4), Cells(LOBCount, UpdatedLastCol + 4)).Formula = "=SUMIF(" & Cells(2, LastCol + 3).Address & ":" & Cells(LastRow, LastCol + 3).Address & "," & Cells(2, UpdatedLastCol + 3).Address(0, 0) & ",$H$2:" & Cells(LastRow, LastCol).Address & ")"
    Address(0, 0) stands for the relative address of any cell, if you omitt the values in the bracket you should get the absolute address.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Absolute Reference While Using Cells Function

    Fantastic, thanks! Was not sure what Address function actually did. Thank you for the explanation!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Apply Absolute Reference to multiplie cells
    By lostinformulas in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-29-2013, 12:16 PM
  2. Calculate a function in descending order with an absolute reference?
    By apaya in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-24-2013, 03:07 PM
  3. Replies: 8
    Last Post: 07-13-2012, 06:48 AM
  4. Invalid function when using absolute reference on another worksheet.
    By krisl in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-14-2009, 04:38 PM
  5. Changing mulitple cells to absolute reference.
    By Randman in forum Excel General
    Replies: 1
    Last Post: 02-20-2005, 06:52 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1