Skip to Content
avatar image
Former Member

BO Analysis - VBA - Find out rows and columns

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

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    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

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Dec 15, 2016 at 12:32 AM

    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

    Add comment
    10|10000 characters needed characters exceeded