ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill down relating to cell value (https://www.excelbanter.com/excel-programming/285549-fill-down-relating-cell-value.html)

posborne

Fill down relating to cell value
 
Good afternoon all!

I have a problem which i'm sure some of you will find easy in Excel!
I have a large two column sheet with a part number and a quantity. What
i need to do is repeat/fill down the part number refering to the qty,
ie:

123456 x 2
234567 x 3

would be

123456
123456
234567
234567
234567

Please help - the limitations of my labelling software are really
getting to me!


---
Message posted from http://www.ExcelForum.com/


Gandei

Fill down relating to cell value
 
Try this macro.
Sub FillDown()

'Pre cond: Part number in column A and qty in column B.
' Single data can't exist in cells of col A and B
i.e. Data present in both An and Bn or nothing present in
both
'Post cond: Results put in col D

Dim i, j, k As Integer

i = 0
j = 0
Do While Range("B1").Offset(i, 0) < vbNullString
For k = 1 To Val(Range("B1").Offset(i, 0))
Range("D1").Offset(j, 0).Value = Range
("A1").Offset(i, 0).Value
j = j + 1
Next k
i = i + 1
Loop

End Sub

-----Original Message-----
Good afternoon all!

I have a problem which i'm sure some of you will find

easy in Excel!
I have a large two column sheet with a part number and a

quantity. What
i need to do is repeat/fill down the part number refering

to the qty,
ie:

123456 x 2
234567 x 3

would be

123456
123456
234567
234567
234567

Please help - the limitations of my labelling software

are really
getting to me!


---
Message posted from http://www.ExcelForum.com/

.


posborne[_2_]

Fill down relating to cell value
 
Thanks Gandei

I have tried to run the macro as you suggest, but get a 'compile error
argument not optional' on 'value = range".

Any ideas would be appreciated!

Thanks in advance

--
Message posted from http://www.ExcelForum.com


Colo[_36_]

Fill down relating to cell value
 
Hi

Modify Gandei's code like this.
(It's a problem with News Group) :D


Code:
--------------------

Range("D1").Offset(j, 0).Value = _
Range("A1").Offset(i, 0).Value

--------------------


And what I suggest is as follows.


Code:
--------------------

Sub Test()
'Part number is placed in A col, Qty is placed in B col
Dim c As Range, i As Long
For Each c In Range([A1], [A65536].End(xlUp))
c.Offset(i, 2).Resize(c.Offset(, 1).Value).Value = c.Value
i = i + c.Offset(, 1).Value - 1
Next
End Sub

--------------------



---
Message posted from http://www.ExcelForum.com/


posborne[_4_]

Fill down relating to cell value
 
Fantastic Colo!

Works perfectly!

Have a nice evening

--
Message posted from http://www.ExcelForum.com


posborne[_5_]

Fill down relating to cell value
 
Fantastic Colo!

Works perfectly!

Have a nice evening

--
Message posted from http://www.ExcelForum.com


posborne[_3_]

Fill down relating to cell value
 
Fantastic Colo!

Works perfectly!

Have a nice evening

--
Message posted from http://www.ExcelForum.com


posborne[_6_]

Fill down relating to cell value
 
Fantastic Colo!

Works perfectly!

Have a nice evening

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com