Generate list from an existing list

edwhite00130

New Member
Joined
Feb 18, 2010
Messages
2
I have a list of the follwing in a 2-column by 4-row matrix:

US-10
AM-15
EU-23
AP-27

I am interested in the VBA code to generate a list of 75 records (10+15+23+27), 10 having the value 'US', 15 having the value 'AM', 23 having the value 'EU', and 27 having the value 'AP'. How do I do this?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi, Try this , It might be what you want !!!
Your data in Columns "A & B".
Code:
[COLOR="Navy"]Sub[/COLOR] MG18Feb37
[COLOR="Navy"]Dim[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]For[/COLOR] Rw = 1 To 4
    [COLOR="Navy"]For[/COLOR] n = 1 To Range("B" & Rw)
        c = c + 1
        Range("C" & c) = Range("A" & Rw)
        Range("D" & c) = Range("B" & Rw)
    [COLOR="Navy"]Next[/COLOR] n
 [COLOR="Navy"]Next[/COLOR] Rw
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks, Mick!

How would I change this macro to post the results to a separate sheet as opposed to column 3 of the current sheet?

Thanks Again,

Ed
 
Upvote 0
Hi, Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG23Feb47
[COLOR="Navy"]Dim[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]For[/COLOR] Rw = 1 To 4
    [COLOR="Navy"]For[/COLOR] n = 1 To Range("B" & Rw)
        c = c + 1
        [COLOR="Navy"]With[/COLOR] Sheets("Sheet2")
            .Range("A" & c) = Range("A" & Rw)
            .Range("B" & c) = Range("B" & Rw)
        [COLOR="Navy"]End[/COLOR] With
    [COLOR="Navy"]Next[/COLOR] n
 [COLOR="Navy"]Next[/COLOR] Rw
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,214,587
Messages
6,120,405
Members
448,958
Latest member
Hat4Life

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