VBA - sum & countif & for loop

HaHa1712

New Member
Joined
Jan 12, 2018
Messages
2
Hi, Bros.
I am having trouble coming up with a formula and was wondering if I could get some assistance/advice.


I have 2 sheets, "Data" and "Sheet1".

The sheet "Data" have 100000 rows with data from column B to column H.

ID11182320
ID22393590
ID37236862
ID41679433
ID54703936

<colgroup><col><col span="7"></colgroup><tbody>
</tbody>

The cell (A2) and cell (B1) in sheet "Sheet1" are the criteria.

A2 =1, B1 =0


How to transform the code below into VBA Code (or another method)?
In sheet 1 Cell(2,2) =
IF(COUNTIF(Data!$1:$1,$A2)=0,0,COUNTIF(Data!$1:$1,B$1))+
IF(COUNTIF(Data!$2:$2,$A2)=0,0,COUNTIF(Data!$2:$2,B$1))+
IF(COUNTIF(Data!$3:$3,$A2)=0,0,COUNTIF(Data!$3:$3,B$1))+
.
.
.
IF(COUNTIF(Data!$10000:$10000,$A2)=0,0,COUNTIF(Data!$10000:$10000,B$1))


Thank you very much.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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