I have a question on how to VBA combination.

Status
Not open for further replies.

ted kim

New Member
Joined
Jul 1, 2022
Messages
4
Office Version
  1. 365
Platform
  1. MacOS
Hi everyone,
Just wondering if anyone can help me out here.

When the value of column A is changed, I want to refresh the combination of columns b, c, and d.
Also, if the cell is empty, I want it to be ignored.

I've gotten help from the community, but it's not working.

VBA Code:
Sub ListAllCombinations()
Dim i&, j&, k&, t&, lrA&, lrB&, lrC&, rng, arr(1 To 100000, 1 To 1)
lrA = Cells(Rows.Count, "B").End(xlUp).Row
lrB = Cells(Rows.Count, "C").End(xlUp).Row
lrC = Cells(Rows.Count, "D").End(xlUp).Row
For i = 2 To lrA
    For j = 2 To lrB
        For k = 2 To lrC
            If IsEmpty(Cells(i, "B")) Or IsEmpty(Cells(j, "C")) Or IsEmpty(Cells(k, "D")) Then
            Else
                t = t + 1
                arr(t, 1) = Cells(i, "B") & "_" & Cells(j, "C") & "_" & Cells(k, "D")
            End If
        Next
    Next
Next
Range("F2").Resize(t, 1).Value = arr
End Sub


What I want the end result to be E column

LOK RPC _ OMS cSKU compare.xlsm
ABCDE
1CodeOption level1Option level2Option level3EX) Result
2888881red888881_red_100
3888881blue888881_red_200
4888881Orange888881_blue_100
5888881100888881_blue_200
6888881200888881_Orange_100
777777blue888881_Orange_200
877777red888881_Orange_200
97777720077777_blue_200_K
1077777K77777_red_200_K
11
12
Sheet1
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Your example data is not working because there is at least one blank cell on each row.
 
Upvote 0
Duplicate to: I want to do a combination in the scope excluding empty cells in the VBA Range area.

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top