Can anyone help me with the following :
I have a worksheet with filled cells in columns P2 to (say) column BL2
I use this line to count the used colums, but it failed :
With ActiveSheet
lKolommen = .Range("P2:" &
.Range("P2").End(xlRight).Address).Columns.Count
End With
Why doesn't it work ?
Per Erik Midtrød - 21 Mar 2008 23:42 GMT
> Can anyone help me with the following :
>
[quoted text clipped - 7 lines]
>
> Why doesn't it work ?
I don't quit know why i doesn't work, but it appears that this is what
you're trying to do:
Sub CountColoumns()
Dim lKolommen As Long
lKolommen = Range("P2").End(xlToRight).Column - Range("p2").Column
+ 1
End Sub
Per Erik
Dave Peterson - 22 Mar 2008 00:02 GMT
Closer to what you started with:
With ActiveSheet
lKolommen = .Range("P2", .Range("P2").End(xlToRight)).Columns.Count
End With
> Can anyone help me with the following :
>
[quoted text clipped - 7 lines]
>
> Why doesn't it work ?

Signature
Dave Peterson
A.Geeraert - 22 Mar 2008 17:36 GMT
Both solutions worked. Many thanks
> Can anyone help me with the following :
>
[quoted text clipped - 7 lines]
>
> Why doesn't it work ?