+ Reply to Thread
Results 1 to 4 of 4

Using Range variable in =sum formula

  1. #1
    Registered User
    Join Date
    12-02-2017
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    55

    Using Range variable in =sum formula

    Please Login or Register  to view this content.
    Above is the part of my code I'm having troubles with.
    As you see, I'm having a selection and I want a =sum formula based on the selection, next to it.
    It gives me the runtime error 1004, Application-defined or object-defined error, and marks the last line.

    I thought that adding .Address to my range-variable would do the trick, but after some searching and other tries I realise I don't know what little tweak is needed to do this.

    In the end it will be part of a loop, but that shouldn't be a problem as soon as this is fixed.

    Kind regards.

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Using Range variable in =sum formula

    Hi, what if you try:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Using Range variable in =sum formula

    Perhaps
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-02-2017
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    55

    Re: Using Range variable in =sum formula

    This worked exactly as I needed. I thought I tried that earlier, but I might have done some of my code improperly. It is fixed now and I can continue.

    Thank you so much, Erwin.

+ 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. Formula in vba to contain a range which is stored in a variable
    By h3llblax in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2018, 02:37 PM
  2. [SOLVED] Range formula with variable
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-20-2015, 04:29 AM
  3. Using a range variable in a formula
    By rachmanchester in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2014, 04:11 PM
  4. [SOLVED] Use a variable in Range.Formula
    By jewelsharma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 05:40 AM
  5. [SOLVED] Use variable range in a formula
    By Mumps1 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 05-20-2013, 07:18 PM
  6. [SOLVED] Copy/Paste Values from Variable Range to Corresponding Variable Range
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2012, 08:20 AM
  7. Range and Variable formula
    By tlm in forum Excel General
    Replies: 3
    Last Post: 02-10-2010, 03:20 PM

Tags for this Thread

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