If in VBA

eng_jamal

New Member
Joined
Oct 5, 2017
Messages
22
hello :
I would ask you how can i write code vba for following:
I would to count within range(g3:g1000) which contain certain date and count range(p3:p1000) which contain the "4130"
and put the results in cells in another sheets

I wrot this but don't work:
if range("g3:g1000")=date and range("p3:p1000")="4130"
cells(2,2)=count(????) how to write this:confused:
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Another option
Code:
Sub myCountif()

    Range("B2").Value = [COUNTIFS(G3:G1000,">=1/1/1900",P3:P1000,4130)]

End Sub
 
Upvote 0
for j= 3 to 1000
if cells(j,7)=cells(1,26) and cells(j,16)=4130 then sum=sum+1
next j
cells(2,2)=sum

the date is in Z1
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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