Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:51:11+00:00 2026-06-15T03:51:11+00:00

I am new to VBA and inherited a requirements tracking spreadsheet from someone else,

  • 0

I am new to VBA and inherited a requirements tracking spreadsheet from someone else, which I am currently updating. The requirements are already grouped and summed correctly with the current VBA code. The particular block I am trying to update (for example, there are multiple levels):

For groups = 1 To i ' Level 3 grouping

    Range(Cells(Start(groups), 1), Cells(Finish(groups), 1)).Rows.Group

    Range("G" & Start(groups) - 1).Formula = "=COUNTIF(E" & Start(groups) & ":E" & Finish(groups) & ",""Requirement"")"

    Range("H" & Start(groups) - 1).Formula = "=COUNTIF(H" & Start(groups) & ":H" & Finish(groups) & ",""Ok"")"

Next

I need to add an extra condition to the COUNTIF, so I am using COUNTIFS. I want to only count requirements that are not level 4 (they can be level 1, 2, 3, or 4). I have tried variations on the following logic:

For groups = 1 To i ' Level 3 grouping

    Range(Cells(Start(groups), 1), Cells(Finish(groups), 1)).Rows.Group

    Range("G" & Start(groups) - 1).Formula = "=COUNTIFS(E" & Start(groups) & ":E" & Finish(groups) & "," & "Requirement" & ",S" & Start(groups) & ":S" & Finish(groups) & ",""<>4"")"

    Range("H" & Start(groups) - 1).Formula = "=COUNTIF(H" & Start(groups) & ":H" & Finish(groups) & ",""Ok"")"

Next

I tried entering the formula(s) manually in the correct cells manually before executing the macro and the formula updated the sums correctly. However, I always get the following when I run the macro:
RunTime Error ‘1004’ Application_defined or object_defined error

I realize I have a lot of quotes and some could probably be consolidated; however, I’m more concerned with why the logic is failing. Could you please help? I’ve spent way too much time on this exploring different avenues.

Thank you in advance!

After this, I will have to learn how to hide each “level 4” requirement (which means that row and the following 2 rows), but that is another topic. I thought I’d try the easier logic first..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:51:12+00:00Added an answer on June 15, 2026 at 3:51 am

    Your use of double quotes inside double quotes is your problem. Use Chr(34) instead.

    Range("G" & Start(groups) - 1).Formula = "=COUNTIFS(E" & Start(groups) & ":E" & Finish(groups) & "," & "Requirement" & ",S" & Start(groups) & ":S" & Finish(groups) & "," & Chr(34) & "<>4" & Chr(34) & ")"
    

    The Chr() method returns the ASCII character at the index number you specify. In this case, Chr(34) returns the double quote character. For more information about ASCII characters, check out the following table:

    http://www.asciitable.com/

    EDIT:

    Alternatively, you could also use double double-quotes, like so:

    Range("A1").formula = "=COUNTIF(B:B,""<>4"")"
    

    instead of

    Range("A1").formula = "=COUNTIF(B:B," & Chr(34) & "<>4" & Chr(34) & ")"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to VBA and building off of someone else's code, who was
So, I inherited some code (below) from someone else and I'm trying to understand
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I'm a new VBA programmer trying to append everything from a TableA in Database1
I am completely new to VBA and need to export multiple graphs from an
I am new to VBA and want to return from a function when I
I am new in VBA. I'd like to hide unhide all the rows from
I am new to VBA in Excel, and I have a basic userform which
can someone please give me some guidelines on this. I'm fairly new to VBA.
I am new to vba and I have problem understanding the workbooks in vba

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.