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