Monday 19 August 2013

How to Find a Value in one colunmn and Replace value in different column

How to Find a Value in one colunmn and Replace value in different column

I am stuck with a simple code error 1004, or Sub not defined depending on
the code I use. I need help comparing numbers from two different sheets,
and then replacing a value in one of the rowa. (EX. sheet1 "A1" = 809565
matches Sheet2 "A28" = 809565, and then I must change the current string
to "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

No comments:

Post a Comment