Streuby
Streuby

Reputation: 23

Sub or Function not defined in VBA for excell

Can some body help me with the reason why below code is returning "sub or function not defined" when I attempt to run a module.

Sub Tokenize()
    Dim txt As String
    Dim i As Integer
    Dim FullName As Variant

    For Counter = 1 To 300
        Set curCell = Worksheet("Sheet1").Cells(Counter, 1)
        txt = curCell.Value
        FullName = Split(txt, " ")
        For i = 0 To UBound(FullName)
            Cells(Counter, i + 1).Value = FullName(i)
        Next i

    Next Counter

End Sub

Upvotes: 0

Views: 2675

Answers (1)

djikay
djikay

Reputation: 10628

I suspect the error is in this line:

Set curCell = Worksheet("Sheet1").Cells(Counter, 1)
                      ^^^

You should replace Worksheet with Worksheets (notice the additional s).

Upvotes: 4

Related Questions