How To Populate Strings Conditionally?

xlmaniac

Well-known Member
Joined
Jul 2, 2009
Messages
527
Office Version
  1. 2010
Platform
  1. Windows
Dear All,
I would like to populate strings based on the SKU & Store combinations.
The count of strings will be equal to # SKUs(Unique Count) X # Stores.
The strings could go into thousands/lakhs of rows.
I have the following sample data set across A1:B5.
IN A Column I have 3 Unique Count of SKUs and in Column B I Have 4 unique count of stores.
I would like to populate the strings(in this case it will be 12) in Column C.
SKUStoreSKU-Store Strings
1a1a
2b1b
3c1c
d1d
2a
2b
2c
2d
3a
3b
3c
3d


Could somebody help me out with the solution Pls?
Regards

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How about
Code:
Sub xlmaniac()
   Dim Ary1 As Variant, Ary2 As Variant, Nary As Variant
   Dim r1 As Long, r2 As Long, nr As Long
   
   Ary1 = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value2
   Ary2 = Range("B2", Range("B" & Rows.Count).End(xlUp)).Value2
   ReDim Nary(1 To UBound(Ary1) * UBound(Ary2), 1 To 1)
   For r1 = 1 To UBound(Ary1)
      For r2 = 1 To UBound(Ary2)
         nr = nr + 1
         Nary(nr, 1) = Ary1(r1, 1) & Ary2(r2, 1)
      Next r2
   Next r1
   Range("C2").Resize(nr).Value = Nary
End Sub
 
Upvote 0
How about
Code:
Sub xlmaniac()
   Dim Ary1 As Variant, Ary2 As Variant, Nary As Variant
   Dim r1 As Long, r2 As Long, nr As Long
   
   Ary1 = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value2
   Ary2 = Range("B2", Range("B" & Rows.Count).End(xlUp)).Value2
   ReDim Nary(1 To UBound(Ary1) * UBound(Ary2), 1 To 1)
   For r1 = 1 To UBound(Ary1)
      For r2 = 1 To UBound(Ary2)
         nr = nr + 1
         Nary(nr, 1) = Ary1(r1, 1) & Ary2(r2, 1)
      Next r2
   Next r1
   Range("C2").Resize(nr).Value = Nary
End Sub

Simply mesmerizing solution!!
It is working like a magic!!
Thank you so much for your kind support.
Really appreciate your help!!:):)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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