VBA not getting count correct
Hello,
I am trying to write line in vba that count used cells in range B3:J6, I am getting wrong count (12-7-4 &11) I want them to get correct are 9-6-3 & 1
Thank you all
Excel 2000
Regards,
Moti
Hello,
I am trying to write line in vba that count used cells in range B3:J6, I am getting wrong count (12-7-4 &11) I want them to get correct are 9-6-3 & 1
Book1 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | XYZ | |||||||||||||
2 | ABC | A|A | A|B | A|C | A|D | A|E | A|F | A|G | A|H | A|I | 1 | 2 | ||
3 | XYZ | 2 | 11 | 1 | 3 | 5 | 0 | 7 | 50 | 21 | 2 | 2 | ||
4 | XYZ | 2 | 4 | 6 | 7 | 8 | 9 | 3 | 2 | |||||
5 | XYZ | 1 | 2 | 3 | 4 | 2 | ||||||||
6 | XYZ | 1 | 5 | 2 | ||||||||||
7 | 6 | 2 | ||||||||||||
8 | 7 | 2 | ||||||||||||
9 | 8 | 2 | ||||||||||||
10 | 9 | 2 | ||||||||||||
11 | 10 | 2 | ||||||||||||
Hoja1 |
Code:
Sub Count()
Dim colLast1 As Long
Dim colLast2 As Long
Dim colLast3 As Long
Dim colLast4 As Long
colLast1 = Range("B3").End(xlToRight).Column
colLast2 = Range("B4").End(xlToRight).Column
colLast3 = Range("B5").End(xlToRight).Column
colLast4 = Range("B6").End(xlToRight).Column
MsgBox colLast1
MsgBox colLast2
MsgBox colLast3
MsgBox colLast4
End Sub
Thank you all
Excel 2000
Regards,
Moti