Skip to Content
0

BO Analysis - VBA - Find out rows and columns

Dec 13, 2016 at 01:11 PM

189

avatar image

Hi Folks,

I follow the VBA blog from Martin Kreitlein to determine the range of the cross tab (rows/columns).

However, the code gives a compile error:
Run-time error '1004'

Method 'Range' of object '_Global' failed.

Any ideas what's wrong?

Thanks for all replies in advance.

Best regards,

Axel

Public Sub Callback_AfterRedisplay()

'Find out the table range
Dim lCols, lRows As Long

--> Error here lCols = Range(“SAPCrosstab1”).Columns.Count
lRows = Range(“SAPCrosstab1”).Rows.Count

End Sub

vba
10 |10000 characters needed characters left characters exceeded

Hi Axel, Further to my previous reply. I did seem to have issues with the "quotes"

If you copied & pasted the text from Martins blog, I would suggest you try re-typing it by hand ( there is only 2 lines)

John

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

John Fitzpatrick Dec 15, 2016 at 12:32 AM
0

Hi Axel,

This worked for me, perhaps it might help get your problem sorted.

################

Sub findRange()
Dim lCols, lRows As Long
With Worksheets("Sheet1")
lCols = .Range("SAPCrosstab1").Columns.Count
lRows = .Range("SAPCrosstab1").Rows.Count
End With
MsgBox (lCols & " By " & lRows)
End Sub

#################

Regards

John

Share
10 |10000 characters needed characters left characters exceeded