Populate cells based on value of another cell

elsg

Active Member
Joined
Mar 16, 2013
Messages
295
Hi
I have a table in excel with some data to create labels, but these labels must be repeated according to the number of volumes.
Example: I have a delivery for X and such delivery has 5 volumes, need to create 5 labels just changing the volume number: 1/5, 2/5, 3/5, 4​​/5 5/5.

I would enter a value in "D1" after running the code, in column "A" shall be filled as follows.


D1 = 7


A2 = 1/7
A2 = 2/7
A2 = 3/7
A2 = 4/7
A2 = 5/7
A2 = 6/7
A2 = 7/7
If "D1" equals 3 then
A2 = 1/3
A2 = 2/3
A2 = 3/3
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
elsg,

Perhaps this in A2 and copy down...


Excel 2007
ABCD
17
21/7
32/7
43/7
54/7
65/7
76/7
87/7
Sheet2
Cell Formulas
RangeFormula
A2=IF(ROW(A2)-1>$D$1,"",IF($D$1<1,"",ROW(A2)-1 &"/"&$D$1))


Hope that helps.
 
Upvote 0
Hi.
Thanks for responding, but I need it to be done via VBA.

Thank you!!
 
Upvote 0
Then try something like this....

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Target.Address = "$D$1" Then Exit Sub
If Target < 1 Then Exit Sub
'**** Edit A11 to suit your maximum volume!!
Range("A2:A11").ClearContents
'**** A11 = max volume 10
                               
For r = 2 To Target + 1
Range("A" & r).Value = r - 1 & "/" & Target
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,202,990
Messages
6,052,962
Members
444,622
Latest member
Kriszilla

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