Excel VBA - Worksheet Function Syntax in VBA

Posted on 2012-09-07
Last Modified: 2012-09-26
Sheets(a.Name).Range("T2").Offset(is + 2, 0).Value = "=Sumif(T" & 2 & ":" & "T" & is + 1 & "," & " '<0'" & ",D" & 2 & ":" & "D" & is + 1 & ")"  

I get the application error on excel when I try to write the worksheet function in vba. The highlighted place is the <0 part which should be like "<" .

Question by:awesomejohn19
    1 Comment
    LVL 39

    Accepted Solution

    you cannot use is as a variable, use somethingelse instead
    a.range("T2").Offset(somethingelse + 2, 0).Formula = "=Sumif(T2:T" & somethingelse + 1 & ",'<0',D2:D" & somethingelse + 1 & ")"

    Open in new window


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
    This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now