AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,052
- Office Version
- 2019
- 2010
- Platform
- Windows
I'm sure Excel is out to get me, with random VBA bugs that suddenly turn up.
This last one was rather nasty and took hours to track down.
I'm repeating this line many times populating rows. I get from 843 to 860
I use cc to change some font colours. All is ok for a while then the colours go nuts.
The reason is cc.address.
Instead of something like $Y$851:$CP$851 it is $Q$860:$Y$860
I can prove this by stopping in the code and printing in the debug window
Set cc = .Range(.Range("Y851"), .Range("CQ851").End(xlToLeft))
? cc.address
$Y$851:$CP$851
Set cc = .Range(.Range("Y" & irow), .Range("CQ" & irow).End(xlToLeft)) [irow is 860]
? cc.Address
$Q$860:$Y$860
This can be repeated at will. But there is nothing (obvious) about line 860 to cause this.
Can anything suggest a reason, or some debugging to try ?
This last one was rather nasty and took hours to track down.
I'm repeating this line many times populating rows. I get from 843 to 860
VBA Code:
With Worksheets("1990+")
Set cc = .Range(.Range("Y" & irow), .Range("CQ" & irow).End(xlToLeft))
end with
The reason is cc.address.
Instead of something like $Y$851:$CP$851 it is $Q$860:$Y$860
I can prove this by stopping in the code and printing in the debug window
Set cc = .Range(.Range("Y851"), .Range("CQ851").End(xlToLeft))
? cc.address
$Y$851:$CP$851
Set cc = .Range(.Range("Y" & irow), .Range("CQ" & irow).End(xlToLeft)) [irow is 860]
? cc.Address
$Q$860:$Y$860
This can be repeated at will. But there is nothing (obvious) about line 860 to cause this.
Can anything suggest a reason, or some debugging to try ?