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 8658685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:49:46+00:00 2026-06-12T15:49:46+00:00

x = 0 For Each cell in Sheets(01).Range(A:A).Cells If cell.Value = aaa And cell.Offset(0,

  • 0
x = 0
For Each cell in Sheets("01").Range("A:A").Cells
If cell.Value = "aaa" And cell.Offset(0, 1).Value = "bbb" Then
x = x+1
End If
Next cell
MsgBox x

Is there a shorter way, pls ?

  • 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-12T15:49:47+00:00Added an answer on June 12, 2026 at 3:49 pm

    You can do this with a formula, like this

    (Excel 2007 or later)

    =COUNTIFS(A:A,"aaa",B:B,"bbb")
    

    (Excel 2003 or earlier)

    =SUMPRODUCT(--(A:A="aaa")*--(B:B="bbb"))
    

    Or, if you have to do it in VBA, use Evaluate

    MsgBox Evaluate("=COUNTIFS(A:A,""aaa"",B:B,""bbb"")")
    
    MsgBox Evaluate("=SUMPRODUCT(--(A:A=""aaa"")*--(B:B=""bbb""))")
    

    EDIT based on your comment

    If rDat and rSec are Range‘s, and ct is the sheet CodeName do it like this

    Dim rDat As Range
    Dim rSec As Range
    Set rDat = ct.[A:A]
    Set rSec = ct.[B:B]
    ct.Range("C6").Value = Evaluate("=COUNTIFS(" & rDat.Address(, , , True) & " ,""a""," & rSec.Address(, , , True) & ",""1"")")
    

    If ct is the sheet Name, use this

    Dim ws As Worksheet
    Dim rDat As Range
    Dim rSec As Range
    Set ws = ActiveWorkbook.Worksheets("ct")
    Set rDat = ws.[A:A]
    Set rSec = ws.[B:B]
    ws.Range("C6").Value = Evaluate("=COUNTIFS(" & rDat.Address(, , , True) & " ,""a""," & rSec.Address(, , , True) & ",""1"")")
    

    If rDat and rSec are strings, use this

    Dim ws As Worksheet
    Dim rDat As String
    Dim rSec As String
    Set ws = ActiveWorkbook.Worksheets("ct")
    rDat = "ct!A:A"
    rSec = "ct!B:B"
    ws.Range("C6").Value = Evaluate("=COUNTIFS(" & rDat & " ,""a""," & rSec & ",""1"")")
    

    Another option (for rDat, rSec as ranges)

    ct.Range("C6").Value = Application.WorksheetFunction.CountIfs(rDat, "a", rSec, "1")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out if a value exists in a range of cells
On each cell of my table view I want to have a bar that
I have UITextField in each Cell of UITableview and I have added UIPickerview as
I have a GridView and each cell has an ImageView with TextView under it.
Suppose you have a JTable and for each cell you want to display three
I have a UITableView with each cell being broken into several sections with a
I have a tableview with an image in each cell. I'm pulling the data
I am trying to paint cell on a html page, where each cell is
I have a 19 X 7 table with a textBox in each cell. Some
I have a UITableView that displays single large images in each cell. The names

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.