# Populate cells based on value of another cell

#### elsg

##### Active Member
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.

Hi.
Thanks for responding, but I need it to be done via VBA.

Thank you!!

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``````

Hi.

Very good!!!

Thank very much!!

Replies
1
Views
138
Replies
2
Views
62
Replies
16
Views
474
Replies
3
Views
84
Replies
2
Views
87

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.

### Which adblocker are you using?

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

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