我试图在我的主要中调用一个sub,并且基本上用这个sub填充另一列。但我收到语法错误。这是为什么?
Option Explicit
Private Sub Form_Load()
Dim mystring As String, i As Long, asciinum As String, f As Long
With Worksheets("sheet1")
For f = 2 To .Cells(.Rows.Count, "I").End(xlUp).Row
mystring = .Cells(f, "I").Value2
prueba1 (mystring, f)
Next f
End With
End Sub
Sub prueba1(mystring, index As Long)
Dim i As Long, asciinum As String
For i = 1 To Len(mystring)
asciinum = LCase(Mid(mystring, i, 1))
If asciinum Like "[aeiou]" Then
.Cells(index, "M") = "First Vowel " + asciinum
Exit For
End If
Next i
End Sub
答案 0 :(得分:2)
prueba1 (mystring, f)
应为prueba1 mystring, f
prueba1(mystring, index As Long)
应为prueba1(mystring AS STRING, index As Long)
.Cells
而不是Cells
。至少应该是Worksheets("sheet1").Cells(index, "M") = "First Vowel " + asciinum