0
我被一个简单的代码错误1004或Sub未定义,具体取决于我使用的代码。我需要帮助比较两张不同工作表中的数字,然后在其中一个rowa中替换一个值。 (EX工作表Sheet1 “A1”= 809565场比赛Sheet2的 “A28”= 809565,然后我必须改变当前字符串为 “地上(I)”。)如何在一个colunmn中查找值并在不同列中替换值
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_# = ""
循环,直到搜索_#= “”
您是否在使用x one或x ell? – pnuts
1,但我决定设置一个固定的范围,因为我知道床单有多大。 – user2569708