Iterative Variable Value Assignment in For Loop VBA

ExcelAnonymous

New Member
Joined
Oct 2, 2018
Messages
1
I am stuck with a VBA code and badly need your help. Here's what I am trying to achieve -

Step 1 : I have to iteratively capture strings in column D (the count of which is mentioned in C2 which will change depending on the data set) - Done
Step 2 : Each of these strings will be split based on "_" and I have to re-combine them since I only need the 2nd, 1st, 3rd, 5th part (in that particular order) - represented further down in column D under 'Output' - Done
Step 3 : I have to join the newly made string in column D and strings in column F and create all possible combinations - represented further down in column F under 'Output' - Done
Step 4 : Supply all created combinations to range C in a different sheet (stuck at this step) :(
Below is the part of code I created. What I am struggling with is, assigning the values in temp(j,k) to a continual range in a different sheet. While j, k have values less than 2 or 3, the range should have values populated in C2:C7. A third loop is conflicting with the already present nested loop. Any help is highly appreciated!

For j = 1 To a_count
For k = 1 To c_count
iet_string = Sheet7.Range("D" & j + 1)
oet_array() = Split(iet_string, "_")
assub_string = oet_array(2) & “_” & oet_array(3) & “_” & oet_array(4) & “_” & oet_array(5)
ic_string = Sheet7.Range("F" & k + 1)
a_string = csub_string & “_” & assub_string & “_” & ic_string
temp(j, k) = a_string
Debug.Print j, k, temp(j, k)​
Next k
Next j
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,219
Messages
6,123,681
Members
449,116
Latest member
HypnoFant

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