Updating repeated names based on a number

Sathisc

Board Regular
Joined
Jul 29, 2008
Messages
103
Hi,

I have a daily task of updating the names in a spreadsheet multiple time with a specified number.

Example:-
As in the given below column A will have names and column B will have numbers.
In Column C the name should appear multiple times repeated based on the number updated in column B

Satz should appear 32 times horizontally and after that Vino should get updated 32 times and so on.

[TABLE="width: 128"]
<tbody>[TR]
[TD]Name[/TD]
[TD] Count[/TD]
[/TR]
[TR]
[TD]Satz[/TD]
[TD="align: right"]32[/TD]
[/TR]
[TR]
[TD]Vino[/TD]
[TD="align: right"]32[/TD]
[/TR]
[TR]
[TD]Merc[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD]Abi[/TD]
[TD="align: right"]34[/TD]
[/TR]
[TR]
[TD]Joh[/TD]
[TD="align: right"]36[/TD]
[/TR]
</tbody><colgroup><col span="2"></colgroup>[/TABLE]


Help is much appreciated.

Thanks,
Sathish Kumar C
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi

Does this do what you want?

Code:
Sub NameRepeat()
LastRow = Range("A65536").End(xlUp).Row

For x = 2 To LastRow

    Person = Cells(x, "A").Value
       
        For y = 3 To Cells(x, "B").Value
            
            Cells(x, y).Value = Person
            
        Next y
        
Next x
            
End Sub

Hope that helps :)
 
Upvote 0
Thank you so much.

Sincere apology, made a mistake it should be vertical in a single column not horizontal.

Can the data appear in the single column name after name
like in Column D alone Satz to appear 32 times and then Vino should be continued 32 times.

Thanks,
Sathish Kumar C
 
Upvote 0
So Column D should contain all the names in one list?

Or would Column D have Satz 32 times, Column E with Vino 32 times etc.
 
Upvote 0
This should do the trick for you then :)

Code:
Sub NameRepeat()
LastRow = Range("A65536").End(xlUp).Row
y = 2 '' Start row of names

For x = 2 To LastRow

    Person = Cells(x, "A").Value
    Repeat = Cells(x, "B").Value
    
        For y = y To y + (Repeat - 1)
    
            Cells(y, 4).Value = Person

        Next y

Next x
            
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,006
Members
452,542
Latest member
Bricklin

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