Duplicate rows based on cell value
Solved/Closed
fireburn
TrowaD
- Posts
- 28
- Registration date
- Monday February 3, 2014
- Status
- Member
- Last seen
- June 23, 2014
TrowaD
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Related:
- Excel duplicate rows based on cell value
- How to duplicate rows in excel based on cell value - Best answers
- Duplicate rows in excel based on cell value - Best answers
- HUGE Inventory Assistance - duplicate a row based on a cell value or quantity ✓ - Forum - Excel
- Copy rows based on a condition ✓ - Forum - Excel
- Auto insert 'x' rows depending on value 'y' - Forum - Excel
- Excel repeat rows based on cell value - Guide
- Excel insert rows based on cell value - Forum - Excel
2 replies
TrowaD
Feb 3, 2014 at 12:11 PM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Feb 3, 2014 at 12:11 PM
Hi Fireburn,
Try this code and let me know how it works:
Best regards,
Trowa
Try this code and let me know how it works:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
If IsNumeric(Target.Value) = False Then Exit Sub
If Target.Value = 0 Then Exit Sub
If Target.Value = vbNullString Then Exit Sub
x = Target.Value
Do
Range(Cells(Target.Row, "A"), Cells(Target.Row, "E")).Copy
Range(Cells(Target.Row + 1, "A"), Cells(Target.Row + 1, "E")).Insert Shift:=xlDown
x = x - 1
Loop Until x = 0
Application.CutCopyMode = False
End Sub
Best regards,
Trowa
Feb 13, 2014 at 09:43 AM
Thank you so much for helping me out with the code it helped me a lot. I don't know so much about excel, I am a nurse working in senior's home. I am currently working on a spreadsheet. I have one more favor to ask you. I am working with data on a spreadsheet, if I enter the name of the client in a cell, I want to reference other data to table or database? wherein it will automatically enter other data on certain cells in the row like for example the postal code, room number etc. I don't know how to achieve it, i've searched a lot and can't find any answer.
Feb 13, 2014 at 10:52 AM
It sounds to me the VLOOKUP formula will do the job.
But without details I can't help you more specifically.
Could you provide sample data like you did in your original post as it is now and how you foresee the result?
Also consider the possibility of posting your workbook (careful with personal data) using a filesharing site like www.speedyshare.com or ge.tt and then post back the download link.
Best regards,
Trowa
Feb 27, 2014 at 09:14 AM
It's me again, the code that you gave me is really helping me a lot, if you could spare your time again and add some modification in your code. Will it be possible that the last cell in "A" when I will execute your code, the first 2 character which I formatted to custom as 00000000 will increment by 1? Like for example, when I execute your code and assuming that A1 is 27022014 the last cell A3 for example , like if we input 3 in F1, it will give us 3 lines right? So the last cell, in A3 as a given exmple will be automatically increment to 28012014. Thank you for your time. Have a good one.
Feb 27, 2014 at 10:53 AM
Great to read that the code is doing it's job.
The easiest way to do this is if the last cell is also the last used cell, meaning there is nothing below it. I'm assuming it is.
And why don't you format the dates as being a date? If we just add 1, then 31012014 would turn into 32012014, which can't be right.
If the last cell is actually the last cell and you formatted the dates as dates then the following will work:
Place this line above the "End Sub" line.
Let me know how this works out for you.
Best regards,
Trowa
Feb 27, 2014 at 10:59 AM