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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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