Copying table down multiple rows, while reference moves down only 1 row.

MelissaBr

New Member
Joined
Oct 4, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I am making a results file and I could use some help!

1698938768310.png


In a sheet called "Info" I can specify how many samples I have. Then, with the code below, it will copy the table until I have that amount. It will also continue the result overview on the right side.

Rich (BB code):
Sub CopyMulti()

Dim amount As Long

amount = Sheets("Info").Range("C2").Value - 1
If Worksheets("Test1").Visible = True Then
Worksheets("Test1").Range("B5:P13").Copy Worksheets("Test1").Range("B14").Resize(9 * amount)
Worksheets("Test1.").Range("R6:T6").Copy Worksheets("Test1").Range("R7").Resize(1 * amount)
End If
End Sub

Let's say I have 3 samples:
TestFile.xlsm
ABCDEFGHIJKLMNOPQRSTU
4
5Nr.LDCD
6Nr.BeforeAfterResultAverageNr.BeforeAfterResultAverage110.0010.00
71LD10.005.001LD10.005.0020.000.00
820.0020.0030.000.00
930.0030.00
10CD10.005.00CD10.005.00
1120.0020.00
1230.0030.00
13
14
15Nr.BeforeAfterResultAverageNr.BeforeAfterResultAverage
160LD10.005.000LD10.005.00
1720.0020.00
1830.0030.00
19CD10.005.00CD10.005.00
2020.0020.00
2130.0030.00
22
23
24Nr.BeforeAfterResultAverageNr.BeforeAfterResultAverage
250LD10.005.000LD10.005.00
2620.0020.00
2730.0030.00
28CD10.005.00CD10.005.00
2920.0020.00
3030.0030.00
31
Test1
Cell Formulas
RangeFormula
R6:R8R6=Results!B8
S6:S8S6=ABS(H7)+ABS(P7)
T6:T8T6=ABS(H10)+ABS(P10)
B7,B25,B16B7=R6
J7,J25,J16J7=B7
G7:G12,O25:O30,G25:G30,O16:O21,G16:G21,O7:O12G7=+((F7-E7)/200)*100


As you can see, the references in the tables for the sample Nr.(or name) gets messed up, as well as the reference in the overview results on the right.
Is there anyone that could help me with this?

I have like 15 sheet that I need this for, but all the tables are different size wise. So if it could be adaptable for my different sheets(I don't mind changing the cells in the code manually at all), that would be amazing!

Thanks!
-Melissa
 

Attachments

  • 1698937308608.png
    1698937308608.png
    27.3 KB · Views: 11

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Maybe not the best way, but I figured it out using the OFFSET function.
=OFFSET($R$7;ROW()/9;0) for the numbering on the left
=ABS(OFFSET($H$1;(ROW()-7)*9;0))+ABS(OFFSET($P$1;(ROW()-7)*9;0)) for the overview on the right
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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