Duplicate Rows Based on Cell Values of different Cells Within Same Row (Cancer Database)

Mouna44

New Member
Joined
Jul 18, 2016
Messages
3
Hello,

I have been working on this "database" program for a couple of days, but just cannot get one thing and would greatly appreciate some help

I have a fill form which is created every time a new sample is added and information gets inserted into their respective columns

V W X Y Z AA AB AC AD AE AF
ID Mouse Passage Virtualtag Date Box RNA Cryo Snap Mice Box Notes

What I want is for a value to read changes in values that is written into columns AA:AE which represent the amount of times to duplicate the row from V:Z and AF be copied and inserted below from left to right and for the number that defines the amount of times the row will be replicated to become a string (category title)

An example would be:

V W X Y Z AA AB AC AD AE AF AG
ID Mouse Passage Virtualtag Date Box RNA Cryo Snap Mice Box NotesCategory
xX yy zz aa bb 2 3 3 2 1 asdf

and the result to be:

V W X Y Z AA AB AC AD AE AF AG
ID Mouse Passage Virtualtag Date Box RNA Cryo Snap Mice Box NotesCategory
xX yy zz aa bb 2 asdf RNA
xX yy zz aa bb 1 asdf RNA
xX yy zz aa bb 3 asdf Cryo
xX yy zz aa bb 2 asdf Cryo
xX yy zz aa bb 1 asdf Cryo
xX yy zz aa bb 3 asdf Snap
xX yy zz aa bb 2 asdf Snap
xX yy zz aa bb 1 asdf Snap
xX yy zz aa bb 2 asdf Mice
xX yy zz aa bb 1 asdf Mice
xX yy zz aa bb 1 asdf Box


The database has other aspects to it that I have amde functional such as "search" and "fill form" but I can seem to get this.. first program ever created and can’t get over this obstacle :(

Here is my code so far:


Rich (BB code):

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer

If Intersect(Target, Range("AA:AE")) 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, "V"), Cells(Target.Row, "Z")).Copy
Range(Cells(Target.Row + 1, "V"), Cells(Target.Row + 1, "Z")).Insert Shift:=xlDown
x = x - 1
Loop Until x = 1

Application.CutCopyMode = False
End Sub


Thank you so much!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,516
Messages
6,125,280
Members
449,220
Latest member
Excel Master

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