Consulting

Results 1 to 3 of 3

Thread: Replace macro from list to another sheet

  1. #1
    VBAX Regular
    Joined
    Oct 2009
    Posts
    8
    Location

    Replace macro from list to another sheet

    Hi guys, can anyone help me with this problem, I am looking for macro that would replace values in sheet1 with values in list in sheet2(even doesnt have to be different sheets if its easier). Practicaly, i need to replace values (number) in column AD with names from another sheet from column B, that suit numbers from column A. Sheet2 is kind of little database and those ID are unique. In the picture I put another workbook so it could be one sheet by another, for better understanding.
    Thanx in advance.
    Attached Images Attached Images

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    Public Sub ProcessData()
        Dim Lastrow As Long
        Dim i As Long
        Application.ScreenUpdating = False
        With Worksheets("Sheet1")
            Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
            For i = 1 To Lastrow
                With .Cells(i, "AD")
                    If .Value2 <> "" Then
                        .Value2 = Application.VLookup(.Value2, Worksheets("Sheet2").Columns("A:B"), 2, False)
                    End If
                End With
            Next i
        End With
        Application.ScreenUpdating = True
    End Sub
    Last edited by Aussiebear; 11-26-2024 at 03:19 PM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2009
    Posts
    8
    Location
    Thanx man, works exactly as needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •