vendredi 7 mai 2021

VBA For loop within IF and For Loop

I'm trying to write a macro to put the name of the steward in a cell if they are assigned to that category. I wrote this code so far but it isn't working. I'm trying to get it so that if a cell of a column in one worksheet matches the cell of another worksheet and if it does, then it will print the name of the steward in a separate cell to identify that that category is owned by that person.

The numbers are in the worksheet Demetri in the range of E27 to E38 and I want to see if the cells in the range BE4 to BE163803 from the worksheet Share_Dump are in the range from the Demetri worksheet.

Sub steward_products()
Dim d, s As Worksheet

Set d = Worksheets("Demetri")
Set s = Worksheets("Share_Dump")

For i = 4 To 163803 Step 1
    For j = 27 To 38 Step 1
        If s.Cells(i, 3) = d.Cells(j, 5) Then
            s.Cells(i, 57) = "Demetri"
        End If
    Next j
Next i

Aucun commentaire:

Enregistrer un commentaire