VBA to count the number of entry in a row and update in count column

swindel

New Member
Joined
Oct 11, 2021
Messages
11
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello,

I am new in this forum and would like to understand the VBA macro, Just wanna know how can I count the number of entries in a row per criteria. I have the Unique ID, and have a couple of data and will insert the count on Count Y and Count X.

IDData 1Data 2Data 3Data 4Data 5Data 6Count YCount X
1​
XYXXX
1​
4​
2​
XXX
0​
3​
3​
YYY
3​
0​
4​
YYYXX
2​
2​
5​
0​
0​
6​
XXYY
1​
2​
7​
YYYXX
3​
2​
 
Hi Micron,

Thank you for your help, but i dont want to loose this opportunity to ask the function, rs.Fields.Count related to the column, how about if rows to be tested, should it be rs.Rows.Count?
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I have no idea what you're asking. I gave you code in my last 2 posts, at least one of which should be giving the result you show in your sample data.
 
Upvote 0
swindel,

See this link. Why not try the code that's been given to you?
 
Upvote 0
Hi Micron,

Yes it did work and i am trying also to understand as well if i will be tested rows instead of column.
 
Upvote 0
It is testing the record (row). It's not testing the field (column).
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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