+ Reply to Thread
Results 1 to 4 of 4

Write SUMIF formula to cell with variables

  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Write SUMIF formula to cell with variables

    Hi

    I struggle with syntax and punctuation in writing a formula to a cell using variables.

    I have this code
    Please Login or Register  to view this content.
    Where
    Dim LastRow As Long
    Dim ColLetter As String
    ColLetter returns E
    LastRow returns 38
    and LastRow -2 would be 36

    This is the result I'm looking for
    Please Login or Register  to view this content.
    I get run time error 1004 "Application defined or Object defined error". I've been wrestling with this for the last 4 hours and can't seem to get the syntax correct. Your help in showing me where I'm going wrong will be greatly appreciated.

    John
    Last edited by jaslake; 04-07-2010 at 07:50 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Write SUMIF formula to cell with variables

    Hi

    Try this.
    Please Login or Register  to view this content.
    You may not be able to split the command line. I can't find the help reference at the moment, but have it mind that there are some string commands you can't split.

    rylo

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Write SUMIF formula to cell with variables

    You can split the strings as long as you're between two strings or between a string and a variable, e.g.
    Please Login or Register  to view this content.
    I think the problem here was that there was an extra ":" in the first bit ("$B6:$B:") and a few unnecessary quotation marks.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Write SUMIF formula to cell with variables

    Hi rylo and Paul

    I also had an extra colon; I was looking at this issue for so long, I totally missed it. As always, thanks for the help . The code worked perfectly.

    John

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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