@ExcelMacroMania, thanks for this lesson. I am new to macros. I ran the code as you have it and nothing happened. Would you be able to lend some assistance?
Thanks! Well, we don't really need a Long variable there because i stores the number of unique values, and i don't think we are going to have thousands of them (definitely not over 32767 which is the limit of the Integer variable). Furthermore, we are also using the variable i as a number reference of the conditional rules, and we definitely cannot have that many conditional rules. Actually, more than about 1000 rules would create issues in Excel. I don't think anybody wants to have that many conditional rules anyway. The problem with the macro comes if we have more than 20 or so because we run out of ColorIndex colors. We should start then from ColorIndex 2 or 3 (instead of 34), and still would have room for just about 50-55 rules. A workaround is using RGB color instead. Hope that helps!
@@nadermounir8228 Aaah, sure, it's declared as an Integer. I just forget to declare variables sometimes in the video but the full code is always in my blog. For this example is here: excelmacroclass.blogspot.com/2023/06/add-conditional-formatting-to-unique.html
@ExcelMacroMania, thanks for this lesson. I am new to macros. I ran the code as you have it and nothing happened. Would you be able to lend some assistance?
Very nice video. 👌 shouldn't we have written "dim i as long "?
Thanks! Well, we don't really need a Long variable there because i stores the number of unique values, and i don't think we are going to have thousands of them (definitely not over 32767 which is the limit of the Integer variable). Furthermore, we are also using the variable i as a number reference of the conditional rules, and we definitely cannot have that many conditional rules. Actually, more than about 1000 rules would create issues in Excel. I don't think anybody wants to have that many conditional rules anyway. The problem with the macro comes if we have more than 20 or so because we run out of ColorIndex colors. We should start then from ColorIndex 2 or 3 (instead of 34), and still would have room for just about 50-55 rules. A workaround is using RGB color instead. Hope that helps!
@@ExcelMacroMania thank u for your reply. I hear u but my question was we have defined i by saying Dim i as byte or something.
@@nadermounir8228 Aaah, sure, it's declared as an Integer. I just forget to declare variables sometimes in the video but the full code is always in my blog. For this example is here: excelmacroclass.blogspot.com/2023/06/add-conditional-formatting-to-unique.html