I apologize if this has been answered before but I have had no luck in finding a viable solution to my quandary.
I am attempting to fix/enhance one of the tools we use by coloring different ranges different colors but only the rows that are used by the data being populated. I have been able to find a solution that works but for some reason it is coloring many more rows than I want it to. If I'm populating only a few rows it colors over 80 rows. The more rows I use the more rows it colors and I haven't had any luck finding out why.
The tool populates columns A-AS and starts on row 9. It is populated with data from a different tab. My tests have been unsuccessful to say the least. Here is what the tool looks like:
Quote Builder:
Here is a snippet of the code I'm working with:
' Color used range of cells
Sheet1.Range("A9:G9" & LastRowNo).Interior.Color = RGB(255, 242, 204)
Sheet2.Range("A9:G9" & LastRowNo).Interior.Color = RGB(255, 242, 204)
Sheet1.Range("H9:M9" & LastRowNo).Interior.Color = RGB(252, 228, 214)
Sheet2.Range("H9:M9" & LastRowNo).Interior.Color = RGB(252, 228, 214)
Sheet1.Range("N9:AI9" & LastRowNo).Interior.Color = RGB(226, 239, 218)
Sheet2.Range("N9:AI9" & LastRowNo).Interior.Color = RGB(226, 239, 218)
Sheet1.Range("AJ9:AS9" & LastRowNo).Interior.ColorIndex = 17
Sheet2.Range("AJ9:AS9" & LastRowNo).Interior.ColorIndex = 17
Please let me know if you need more information, I tried to be as specific as I could.
To clarify to all that are trying to help with this issue. The code above works except that it is coloring more rows than I need it to by a significant amount. I only need it to color the used rows starting at row 9 going down to how ever many lines the user populates. This could be as few as 1 line to well over 200 lines. Basically, however many lines are needed by the user. Thanks to all in advance.
Here are the changes I've made that is a lot closer to what I need but still not all the way there:
' Color used range of cells
Sheet1.Range("A9:G1" & LastRowNo).Interior.Color = RGB(255, 242, 204)
Sheet2.Range("A9:G1" & LastRowNo).Interior.Color = RGB(255, 242, 204)
Sheet1.Range("H9:M1" & LastRowNo).Interior.Color = RGB(252, 228, 214)
Sheet2.Range("H9:M1" & LastRowNo).Interior.Color = RGB(252, 228, 214)
Sheet1.Range("N9:AI1" & LastRowNo).Interior.Color = RGB(226, 239, 218)
Sheet2.Range("N9:AI1" & LastRowNo).Interior.Color = RGB(226, 239, 218)
Sheet1.Range("AJ9:AS1" & LastRowNo).Interior.ColorIndex = 17
Sheet2.Range("AJ9:AS1" & LastRowNo).Interior.ColorIndex = 17