我知道这个错误是什么,但我无法弄清楚它被调用的原因。我将脚本运行到光标,它似乎在lin 6 [Title = Application ....]上中断。 VBA不支持我的代码怎么办?
Function Term_gen()
TermRow = 3 \\Starting Row on Term Tab
ResultsRow = 3 'Starting Row on Results tab
Do Until IsEmpty(Worksheets("Results").Range("A:A").Value) 'Loop through a column in "Results" tab until cells are blank
Do Until IsEmpty(Worksheets("Terms").Range("N:N").Value) 'Loop through column in "Terms" tab until cells are blank
Lefty = Left(Worksheets("Terms").Range("N" & TermRow).Value, 6) 'Take left 6 letters in the designated cell
Location = Application.WorksheetFunction.Match(Lefty, Worksheets("Results").Range("ResultsRow:ResultsRow"), 0) 'Use the match function to find the location of the string found in Lefty, in the row designated
If Location IsError Then 'If the tern Row produces an error
TermRow = TermRow + 1 'Go to the next Row in Terms and reset loop
Else
Title = Application.WorksheetFunction.Index(Worksheets("Results").Range("A1:CR200000"), Location, ResultsRow) 'Store the value of the term found in the row
Loop 'End the loop
whole_name = Title & Worksheets("Results").Range("X1").Value 'Concatinate the Title Value with a fixed value in spreadsheet
If whole_name IsError Then 'If the Vlookup Produces an error
TermRow = TermRow + 1 'Go to next row in Terms and reset loop
Else
term = Application.WorksheetFunction.VLookup(whole_name, Worksheets("Terms").Range("N:O"), 2, 1) 'Vlookup of the whole term in the term sheet
Worksheets("Test_Sheet").Range("A" & ResultsRow).Value = term 'Print Term in designated cell
ResultsRow = ResultsRow + 1 'Go to next row. Start loop over.
Loop
End Function