Repeating a Text Cells a certain number of times vertically

GusAlmeida

New Member
Joined
Apr 23, 2014
Messages
5
I have a list of stocks as shown here:[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A UN Equity[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]AA UN Equity[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]AAPL UN Equity[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]....[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I will create a new column that has the Date (a certain time period). Example:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]18-04-2014[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]19-04-2014[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]20-04-2014[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]21-04-2014[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]22-04-2014[/TD]
[/TR]
</tbody>[/TABLE]

Now, how can I put the name of the stocks on the first column for each date. As shown here:


[TABLE="width: 500"]
<tbody>[TR]
[TD]A UN Equity[/TD]
[TD]18-04-2014[/TD]
[/TR]
[TR]
[TD]A UN Equity[/TD]
[TD]19-04-2014[/TD]
[/TR]
[TR]
[TD]A UN Equity[/TD]
[TD]20-04-2014[/TD]
[/TR]
[TR]
[TD]A UN Equity[/TD]
[TD]21-04-2014[/TD]
[/TR]
[TR]
[TD]A UN Equity[/TD]
[TD]22-04-2014[/TD]
[/TR]
[TR]
[TD]AA UN Equity[/TD]
[TD]18-04-2014[/TD]
[/TR]
[TR]
[TD]AA UN Equity[/TD]
[TD]19-04-2014[/TD]
[/TR]
[TR]
[TD]AA UN Equity[/TD]
[TD]20-04-2014[/TD]
[/TR]
[TR]
[TD]AA UN Equity[/TD]
[TD]21-04-2014[/TD]
[/TR]
[TR]
[TD]AA UN Equity[/TD]
[TD]22-04-2014[/TD]
[/TR]
[TR]
[TD]AAPL UN Equity[/TD]
[TD]18-04-2014[/TD]
[/TR]
[TR]
[TD]AAPL UN Equity[/TD]
[TD]19-04-2014[/TD]
[/TR]
[TR]
[TD]AAPL UN Equity[/TD]
[TD]20-04-2014[/TD]
[/TR]
[TR]
[TD]AAPL UN Equity[/TD]
[TD]21-04-2014[/TD]
[/TR]
[TR]
[TD]AAPL UN Equity[/TD]
[TD]22-04-2014[/TD]
[/TR]
</tbody>[/TABLE]

As you can imagine I don't have 3 stocks only, I have hundreds of them.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Your Stocks in column "A"
Your Dates in Column "B"
Results in columns C & D.
Code:
[COLOR="Navy"]Sub[/COLOR] MG23Apr36
[COLOR="Navy"]Dim[/COLOR] RngA [COLOR="Navy"]As[/COLOR] Range, DnA [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] RngB [COLOR="Navy"]As[/COLOR] Range, DnB [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] RngA = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]Set[/COLOR] RngB = Range(Range("B1"), Range("B" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] DnA [COLOR="Navy"]In[/COLOR] RngA
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] DnB [COLOR="Navy"]In[/COLOR] RngB
        c = c + 1
        Cells(c, "C") = DnA
        Cells(c, "D") = Format(DnB, "dd/mm/yyyy")
    [COLOR="Navy"]Next[/COLOR] DnB
[COLOR="Navy"]Next[/COLOR] DnA
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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