Assistance with ANDIF

PierreT

New Member
Joined
Nov 7, 2014
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Good day Forum members,

I hope you are all doing well. As I’m new to VBA, I’m looking for some assistance to formulate my code using ANDIF (assuming ANDIF is the right condition).

I would like to be able to count the number of rows in my WS that meets two conditions. First, a specific word in column A (range A1:A300). Then, if the date in column B (range B1:B300) is <=> than today.

Example: if the text “Tp A” is in A5 and its corresponding date in B5 is < today then count them and write that number in cell A305. If the text “Tp A” is in A10 and its corresponding date in B10 is = today then count them and write that number in cell A306. If the text “Tp A” is in A111 and its corresponding date in A111 is > today then count them and write that number un cell A307.

The same thing would apply for other text such as “Tp B” and other with the information in B305, 306, 307 and so on for the remainder.

I managed to come up with the following code but obviously it is beyond my capability.
VBA Code:
Private Sub Workbook_Open()

Range("A305") = WorksheetFunction.CountIf(Range("A:A"), "Tp A")

End Sub
Any help on the matter would be much appreciated. Thank you kindly.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Note that a COUNTIFS function was introduced with Excel 2010 that allows you to have multiple conditions.
See: COUNTIFS function - Microsoft Support
 
Upvote 0
Solution
Wow!!! Easier than I thought. Thank you so much for your expertise/input.
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,938
Latest member
Aaliya13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top