Hi
I have the codes to perform the following:
1. I have data in sheet1
2. I have a range of numbers in sheet3, from A1 to A10
3. If the data in column1 of sheet1 matches to that in A1 to A10 in sheet3, then add "S" to the end of the data in column27 and then make column26 the same as column27.
Please advise how to fix as it doesn't work
QUOTE
UNQUOTE
I have the codes to perform the following:
1. I have data in sheet1
2. I have a range of numbers in sheet3, from A1 to A10
3. If the data in column1 of sheet1 matches to that in A1 to A10 in sheet3, then add "S" to the end of the data in column27 and then make column26 the same as column27.
Please advise how to fix as it doesn't work
QUOTE
Code:
Sub sbNameRange()
Dim WB As Workbook
Dim dataSH As Worksheet, lookupSHsub As Worksheet
Dim dataRng As Range, lookupRngsub As Range
Dim rCell As Range
Dim Res As Variant
Dim LRow As Long
Dim i As Integer
Const sDataSheet As String = "Sheet1"
Const sLookupSheet3 As String = "Sheet3"
Const sLookupRange3 As String = "A1:A10"
Set WB = ThisWorkbook
With WB
Set dataSH = .Sheets(sDataSheet)
Set lookupSHsub = .Sheets(sLookupSheet3)
End With
Set lookupRngsub = lookupSHsub.Range(sLookupRange3)
With dataSH
LRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set dataRng = .Range("A1:A" & LRow)
End With
i = 2
For Each rCell In dataRng.Cells
With rCell
Res = Application.Match(.Value, lookupRngsub, 0)
If Not IsError(Res) _
And .Offset(0, 0).Value = sLookupRange3 Then
Cells(i, 27) = Cells(i, 27) & " " & "S"
Cells(i, 26) = Cells(i, 27)
End If
End With
Next rCell
End Sub
Last edited by a moderator: