我遇到了一个简单的代码错误 1004,或者根据我使用的代码未定义 Sub。我需要帮助比较两个不同工作表中的数字,然后替换其中一个 rowa 中的值。 (例如 sheet1 "A1" = 809565 匹配 Sheet2 "A28" = 809565,然后我必须将当前字符串更改为 "Above Ground(I)"。)
Set dbsheet = ThisWorkbook.Sheets("Sheet1")
Set dbsheet_1 = ThisWorkbook.Sheets("Export_For_WMIS_Recon")
Col_Len = dbsheet.Cells(Rows.Count, 1).End(x1UP).Row
Col_Len_1 = dbsheet_1.Cells(Rows.Count, 1).End(x1UP).Row
For x = 1 To Col_Len
For i = 1 To Col_Len_1
Search_num = dbsheet.Cells(x, 1)
Comp_num = dbsheet_1.Cells(i, 1)
Comp_word = dbsheet_1.Cells(i, 3)
If Search_# = Comp_# And Comp_word = "Aboveground" Then
Comp_word = "ABOVE GROUND(I)"
End If
Next i
Next x
End Sub
代码 2:
row_number = 0
r_number_2 = 0
Do
DoEvent
r_number_2 = r_number_2 + 1
Search_# = ThisWorkbook.Sheets("Sheet1").Range("A" & row_number)
Comp_# = ThisWorkbook.Sheets("Export_For_WMIS_Recon").Range("A" & row_number)
If Search_# = Comp_# And ThisWorkbook.Sheets("Export_For_WMIS_Recon").Range("C" & row_number) = "Aboveground" Then
ThisWorkbook.Sheets("Export_For_WMIS_Recon").Range("C" & row_number) = "ABOVE GROUND(I)"
End If
Loop Until Comp_# = ""
循环直到 Search_# = ""