调用2个定义的参数

我想在我的主要调用一个子,基本上填补了这个子的另一列。 但是我得到一个语法错误。 为什么是这样?

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 

  • prueba1 (mystring, f)应该是prueba1 mystring, f
  • prueba1(mystring, index As Long)应该是prueba1(mystring AS STRING, index As Long)
  • With … End With在prueba1中没有父工作表,但是您使用.Cells而不是Cells 。 至less应该是Worksheets("sheet1").Cells(index, "M") = "First Vowel " + asciinum