Generate concatenated text in new rows, based on Yes/No values in columns. VBA Button Macro

Viewed 54

Having some trouble figuring this out. Here is the goal:

  1. let's say I import some values with the following columns (Products, Category, Mobile, Desktop, Tablet)

Imported Values

  1. Let's say I have a naming convention that is defined (doesn't change)

Hard defined naming convention (used for concatenation)

After clicking a button, my VBA code should be able to concatenate the Products values with the defined naming convention, based on the Yes/No criteria. Here is what I'm trying to get as the end result:

End goal after clicking VBA button

Tried a ton of things, here is an example of what I tried for Products of Category = Chocolate:

Code in Text Format:

    'Example Attempt for Products that are of Category = Chocolate'
     
    Dim chocolateOption1 As String  'Chocolate Mobile'
    Dim chocolateOption2 As String 'Chocolate, Desktop'
    Dim chocolateOption3 As String 'Chocolate, Tablet'
     
    startingLine = 2 'This is just starting from the second row'
     
    With SavedData 'Name of the open worksheet'
        Do While .Cells(startingLine, 2) <> ""
            If .Cells(startingLine, 2) = "Chocolate" And 
            .Cells(startingLine, 3) = "Yes" Then
                  chocolateOption1 = .Cells(startingLine, 1) & 
                  .Cells(10,7) 'Concatenation to generate 
                  DarkChocolate_Chocolate_Mobile'
            ElseIf .Cells(startingLine, 2) = "Chocolate" And 
            .Cells(startingLine, 4) = "Yes" Then
                  chocolateOption2 = .Cells(startingLine, 1) & 
                  .Cells(11,7) 'Concatenation to generate 
                  DarkChocolate_Chocolate_Desktop'
            ElseIf .Cells(startingLine, 2) = "Chocolate" And .Cells(startingLine, 5) = "Yes" Then
    chocolateOption3 = .Cells(startingLine, 1) & .Cells(12,7) 
    'Concatenation to generate DarkChocolate_Chocolate_Tablet'
    Else
    chocolateOption1 = "Please import a valid Category and try again…"
    chocolateOption2 = ""
    chocolateOption3=""
    End If
     
    .Cells(startingLine, 6) = chocolateOption1
    .Cells(startingLine, 6) = chocolateOption2
    .Cells(startingLine, 6) = chocolateOption3
     
    startingLine = startingLine + 1 'move to the next line once Dark 
    Chocolate product asset names are all generated and complete'
    Loop
    End With

Thank you for your help!

0 Answers
Related