MichaelRSnow
Active Member
- Joined
- Aug 3, 2010
- Messages
- 409
Hi, can anyone help, i'm trying to get sheet 2 (Slave Fund Numbers column A to replace all numbers found from Sheet 1 column D with their replacing numbers Sheet 1 column E
e.g. D2 is 1, E2 is 3, Sheet 2 Column A has 30 values of 1 = replace those 30 1's with new number 3. The code below only changes the first one found and not all of them? Help!!!
Private Sub CommandButton2_Click()
Dim i As Long
Dim LastRow As Long
Dim sh As Worksheet
Dim cell As Range
Set sh = Worksheets("Slave Fund Numbers")
With ActiveSheet
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
For i = 2 To LastRow
Set cell = Nothing
On Error Resume Next
Set cell = sh.Columns("A").Find(.Cells(i, "D").Value)
On Error GoTo 0
If Not cell Is Nothing Then cell.Value = .Cells(i, "E").Value
Next i
End With
End Sub
e.g. D2 is 1, E2 is 3, Sheet 2 Column A has 30 values of 1 = replace those 30 1's with new number 3. The code below only changes the first one found and not all of them? Help!!!
Private Sub CommandButton2_Click()
Dim i As Long
Dim LastRow As Long
Dim sh As Worksheet
Dim cell As Range
Set sh = Worksheets("Slave Fund Numbers")
With ActiveSheet
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
For i = 2 To LastRow
Set cell = Nothing
On Error Resume Next
Set cell = sh.Columns("A").Find(.Cells(i, "D").Value)
On Error GoTo 0
If Not cell Is Nothing Then cell.Value = .Cells(i, "E").Value
Next i
End With
End Sub