Macro Help: Reproducing Value in cell

Ytime

New Member
Joined
Mar 24, 2009
Messages
3
Hey Guys,

Ok so here a simple explanation of my problem.

I have a list of stores in each store i have a number value which reprisents how many cartons of a product have been sold into the store. Lets say the store name is in column A and the QTY of cartons sold in is in column B.
I need a macro that will take each store look for the QTY of cartons they sold in and reproduce the store name on a different sheet in one column.

so Store CL Warnumbull, QTY 5
becomes

CL Warnumbull
CL Warnumbull
CL Warnumbull
CL Warnumbull
CL Warnumbull

Thanks for your help
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi and Welcome to the Board.
Do you really need macro ??
You could do a sort ascending by column B and then copy the rows in column A to your new sheet.
Having said that, you question simply requires ALL names in column A, which doesn't make much sense to me.
Maybe try to be a bit more specific, eg, what criteria in column B do you need to find a store name in A

Regards
Michael M
 
Upvote 0
Sorry i should of provided a bit more info!

Currently i am running a sales drive for a string of products in stores with incentives for cartons sold in. However its going to be a raffle for example 5 cartons sold in = 1 raffle.

The data comes out as

Visit Date,Store,Product,QTY Sold in
and then i have manually added "Raffle"(Formula that takes the number of tickets achieved from the QTY to determine how many times i want this particular store to appear)

The idea is if someone has got a value of 2 for the raffle in a store i would like to reproduce the store twice.

with this giant list of stores i would of used the randbetween forumla to randomly select a winner.
 
Upvote 0
Hmm, that's an interesting way to do it.
I'm afraid my VBA isn't as good as most, but I'm sure there will be some simple lines of code provided from other users.
I think you will need a do While loop....but we'll see.
Regards
Michael M.
 
Upvote 0
Ytime
I did some searching and found this code.
Code:
Sub Repeat()
Dim rng As Range
Dim NoRows As Long
    Set rng = Range("A1")
    While rng.Value <> ""
        NoRows = rng.Offset(, 1) - 1
        rng.Offset(1).Resize(NoRows).EntireRow.Insert
        rng.Offset(1).Resize(NoRows) = rng.Value
        Set rng = rng.Offset(NoRows + 1)
    Wend
End Sub

Which does as you require, BUT, I'd suggest you copy your original sheet to a backup sheet and run it from there.
The reason being it creates the new entries back into column A
If I find an improvement I'll let you know.
Hope this helps
Regards
Michael M
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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