Quote Originally Posted by Kaper View Post
First: have you changed
Set c2 = 32000
into
c2 = 32000
As c2 is declared as Integer (it would be wiser to declare it as long) it cannot be Set. You can Set only object variables.

so:
Public Function Main_HideRows(ByVal rng As Range, tgbtn As ToggleButton)

Dim sht As Excel.Worksheet
Dim c As Integer
Dim c2 As Integer

Set sht = Arkusz1
'Set
c2 = 32000
'...
if it does not help, press Debug when code stops, chech which code line is highlited in yellow and let us know.

I have made this change. However, I want to turn my sub routine into a function so that I can then reuse it for the other toggle buttons by just passing through the named range and toggle button name.

However, when I try to call it, it says object required.

Any suggestions ?

Bilal