Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50298

Function in two or more places

$
0
0
Hello,
I have a function which is working for one place in the Sub code:

Code:


Public Function Counter(ByVal ctl As Control, s As Double, rng As Range) As Double
Dim size As Double
With UserForm1.Frame1


   
      size = Application.WorksheetFunction.RoundUp(Len(ctl) / 52, 0)
   
       
       
    With rng
        .RowHeight = (size * 10)
        Counter = .RowHeight
       
    End With

End With
   
End Function

But When I call it in more than one place, I get an error <ByRef arugment type mismatch>

I call the function like:

Code:

With rngMotivation
            .Offset(0, 1).Value = "• " & txtMotivation.Text
           
            size1 = Counter(UserForm1.txtMotivation, 0, rngMotivation)
            .RowHeight = size1
           
           
        End With

It highlights the third parameter - rngMotivation


Thanks!

Viewing all articles
Browse latest Browse all 50298

Latest Images

Trending Articles



Latest Images