Excel VBA 15 digit limitation for countif and how to overcome it

Sunscreen

New Member
Joined
Aug 1, 2022
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello all! First of all, many thanks for the help from other posts as i have been using them to improve my Excel/VBA skills. However, no help i have been able to found for this particular situation. Here is the main idea (which i have already tested sucesfully)

I need to compare the values, cell by cell, between two ranges, as the information from one side has to match the other, and in case there is a discrepancy, insert a row with data, and do some other stuff. I use a For loop to go through the fixed range, storing the value of the cell in a variable, and then use it as a the value to count in the countif.

While for most of the data stored it works just fine, there is issue with some values, which are more than 15 digits long and only numbers, which makes the count if "useless" as the last digits are different, but the first 15 are the same. I have read that for excel, using sumproduct is a way to surpass this limitation, but cannot find a "good way" to implement it in my code. Are there any other options to surpass the 15 digit limitation?
Further conditions:
1) One range is fixed, and the other one is variable, as rows will be inserted here and there when needed. Preferable if i could take full column.
2) Ranges are in separated worksheets, same workbook. Fixed range is 3rd sheet, Variable range is 2nd sheet.
3) If the countif(or its "similar" formula") returns 0 in the range from the second sheet, there are two other columns in the third sheet two use to compare and find. So the main range is column B, and the "auxiliar" are C and D. If no data is found, it will take data from the fixed range to paste it in the variable.


Most of the code has been already implemented, only would need to implement that "extra condition" to avoid Excel from usign only the 15 digits.

Appreciated any help. If requested, I could try to implement the full code tomorrow morning (CEST Time)
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
To my knowledge, any cell using numeric format can only hold 15 significant digits and everything beyond that becomes 0's. The only way to get around that is to format the cells as Text before entering the 16+ digit numbers and handling that accordingly in your code.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,849
Members
449,194
Latest member
HellScout

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