Getting a “Compile Error: Expected: End of Statement” when trying to return a calculated value from a function
我对一个函数进行了编码,它在第三行中查找第一列中有一个空单元格,但我不知道如何返回这个整数。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | Function FindEmptyColumn() ' Find the first empty column to paste data into ThisWorkbook.Activate Worksheets("Black Cam Raw Data").Activate Dim dCounter As Double dCounter = 1 Dim iColumn As Integer Do Until Cells(3, dCounter) ="" iColumn = dCounter dCounter = dCounter + 1 Loop iColumn = iColumn + 1 Return iColumn End Function Sub CMM_93Cam(ByVal wbTempName As Workbook) ' ' CMM_93Cam Macro ' This subroutine imports data from the CMM Report for a 195C93 Cam flatness measurement into this file. ' iColumn = FindEmptyColumn() |
基本上,当我键入"返回IColumn"语句时会得到一个错误。如何让函数返回存储在IColumn中的值?
vba中的
而不是:
1 | Return iColumn |
用途:
1 | FindEmptyColumn = iColumn |
在vba中,
msdn:gosub…返回语句