Forum Discussion
VBA Coding Help - Multiple Criteria 'If Range'
So what is happening wrong? My first step would be to add ( ) around all the groups. you have a string of A AND B OR C AND D OR ... and I wouldn't be surprised if that is not acting the way you think / hope it is.
- JenstarzieMay 01, 2025Copper Contributor
Hi, Thanks for your reply. Nothing happens at all at the moment so there is obviously something in the code that isn't registering. I will try adding the brackets around the groups and report back on how that goes.
- m_tarlerMay 01, 2025Bronze Contributor
so i threw the code into a vba sheet and it seems to "work".
A few tips and good practices to consider include
- defining the range object (e.g. ActiveSheet.Range.... or ActiveWorkbook.Sheets("MySheet").Range...)
- Use Breaks (click on gray bar to left of code to toggle break points) and Step through code (F8)
- Use the immediate window to 'try' things out (e.g. PRINT Activesheet.range("D9").value)
- highlight parts of the code and hover over it to see immediate value where possible
notice in this image I have a breakpoint on the IF, then hit F8 to move to the next line and highlighted the text/code "Range("D9").Value <= 450001" and hovered over it to see the tooltip/pop-up window showing that it evaluates to False
hope that helps