how to add the above row x times in excel based on the number y which can change

BlackHairSasha

New Member
Joined
Sep 20, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I am trying to make an excel file for my parents so that they have it easier than writing all the info in a book X amount of times.

i have A; B; C; D; E; F; G; H; I; J; and L columns and want to automate and duplicate the data in A to G in rows below xn-1 times when

there is a number on Hx cell x amount of times,

where x can be from 1 to 50.



r/excel - how to add the above row x times in excel based on the number y which can change
before typing 10



r/excel - how to add the above row x times in excel based on the number y which can change
example data after inputting 10 or 5 respectively

thus will be inputting all the details in the rows 17 and 27

I tried VBA but I need to go and click macro every time. is there it can be used via formula, please?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
@BlackHairSasha Welcome

If you are not averse to using vba then it should be far more efficient than messing with formulas?

Maybe try the below pasted into the sheet's code module.
That way, it will trigger automatically and not require a button.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim MyRng As Range
 Dim os As Integer
 
  If Not Target.Column = 8 Then Exit Sub
  If Not Target.Row = Range("A" & Rows.Count).End(xlUp).Row Then Exit Sub
  If Target = vbNullString Then Exit Sub
  If Not IsNumeric(Target) Then Exit Sub
 
  Application.EnableEvents = False
  Application.ScreenUpdating = False
  Set MyRng = Range("A" & Target.Row & ":G" & Target.Row)
 
  For os = 1 To Target - 1
    MyRng.Offset(os, 0).Value = MyRng.Value
  Next os
  Application.ScreenUpdating = True
  Application.EnableEvents = True

End Sub
Hope that helps.
 
Upvote 0
@BlackHairSasha Welcome

If you are not averse to using vba then it should be far more efficient than messing with formulas?

Maybe try the below pasted into the sheet's code module.
That way, it will trigger automatically and not require a button.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim MyRng As Range
 Dim os As Integer
 
  If Not Target.Column = 8 Then Exit Sub
  If Not Target.Row = Range("A" & Rows.Count).End(xlUp).Row Then Exit Sub
  If Target = vbNullString Then Exit Sub
  If Not IsNumeric(Target) Then Exit Sub
 
  Application.EnableEvents = False
  Application.ScreenUpdating = False
  Set MyRng = Range("A" & Target.Row & ":G" & Target.Row)
 
  For os = 1 To Target - 1
    MyRng.Offset(os, 0).Value = MyRng.Value
  Next os
  Application.ScreenUpdating = True
  Application.EnableEvents = True

End Sub
Hope that helps.
hi,

thank you for ur time and effort but i already i have the VBA code which can be found bellow

Sub Autorows()
Dim wsc As Worksheet 'worksheet copy
Dim wsd As Worksheet 'worksheet destination

Dim lrow As Long 'last row of worksheet copy
Dim crow As Long 'copy row
Dim drow As Long 'destination row

Dim multiplier As Integer
Dim i As Integer 'counting variable for the multiplier

Set wsc = Sheets("Sauda Entry")
Set wsd = Sheets("Sauda Entry with Design")

lrow = wsc.Range("h" & wsc.Rows.Count).End(xlUp).Row
drow = 2

With wsc

For crow = 2 To lrow 'starts at 2 because of the header row

multiplier = .Cells(crow, 8).Value 'copies the value in column h

For i = 1 To multiplier

wsd.Cells(drow, 1).Value = .Cells(crow, 1).Value
wsd.Cells(drow, 2).Value = .Cells(crow, 2).Value
wsd.Cells(drow, 3).Value = .Cells(crow, 3).Value
wsd.Cells(drow, 4).Value = .Cells(crow, 4).Value
wsd.Cells(drow, 5).Value = .Cells(crow, 5).Value
wsd.Cells(drow, 6).Value = .Cells(crow, 6).Value
wsd.Cells(drow, 7).Value = .Cells(crow, 7).Value
wsd.Cells(drow, 8).Value = .Cells(crow, 8).Value


drow = drow + 1 'increasing the row in worksheet destination

Next i

Next crow

End With

End Sub
*******************************

it gives me the output in a new sheet which I m ok with.

now I have more questions as my parents say that they can have different quantity sent on different dates for the same order code
for example if "Quantity Remaining" is "0" its well and fine but it its above that they need to send remaining at a later date upto a maximum quantity (factor is the volume / quality) which varies depending on the type quality
how do i incorporate that i on the excel file that if there is quality remaining it provides them with a colum for a future date...sorry i dont eve have a logic to this problem

autosauda book1
ABCDEFIJKLM
1Order NumberDateBuyer NameQualityWeaver NameRateQuantity per DesignDesign Code/NumberQuantity SentQuantity Sent - DateQuantity Remaining
2786519/09/2022abcA123xyz3550,0a1235019/09/20220
3786519/09/2022abcA123xyz3550,0b1232519/09/202225
4786620/09/2022abv1e123adsf456,3a1246
5786620/09/2022abv1e123adsf456,3b1246
6786620/09/2022abv1e123adsf456,3a1256
7786620/09/2022abv1e123adsf456,3b1256
8786620/09/2022abv1e123adsf456,3a1266
9786620/09/2022abv1e123adsf456,3b1266
10786620/09/2022abv1e123adsf456,3a1276
11786620/09/2022abv1e123adsf456,3b1276
12786721/09/2022weFWEFFRCQ508,7a1289
13786721/09/2022weFWEFFRCQ508,7b1289
14786721/09/2022weFWEFFRCQ508,7a1299
15786721/09/2022weFWEFFRCQ508,7b1299
16786721/09/2022weFWEFFRCQ508,7a1309
17786721/09/2022weFWEFFRCQ508,7b1309
18786721/09/2022weFWEFFRCQ508,7a1319
19786721/09/2022weFWEFFRCQ508,7b1319
20786721/09/2022weFWEFFRCQ508,7a1329
21786822/09/2022RZRTUdffg4114,8b132115
22786822/09/2022RZRTUdffg4114,8a133115
23786822/09/2022RZRTUdffg4114,8b133115
24786822/09/2022RZRTUdffg4114,8a134115
25786822/09/2022RZRTUdffg4114,8b134115
26786923/09/2022sashaergqq750,0a13550
27786923/09/2022sashaergqq750,0b13550
28786923/09/2022sashaergqq750,0a13650
29786923/09/2022sashaergqq750,0b13650
Sauda Entry with Design
Cell Formulas
RangeFormula
I2:I29I2=G2/H2
M2:M29M2=I2-K2
 
Upvote 0
If you are happy with your vba code then you can still call it using the Worksheet Change event of the Sauna Entry sheet, similar to below,
Or you attach your macro to a button that can reside at the top of the sheet?
Do you realise that your code rewrites the whole listing in the Sauna Entry With Design sheet, top to bottom, each time it runs?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim MyRng As Range
 Dim os As Integer
 
  If Not Target.Column = 8 Then Exit Sub
  If Not Target.Row = Range("A" & Rows.Count).End(xlUp).Row Then Exit Sub
  If Target = vbNullString Then Exit Sub
  If Not IsNumeric(Target) Then Exit Sub
 
  Application.EnableEvents = False
  Application.ScreenUpdating = False
  Call Autorows
  Application.ScreenUpdating = True
  Application.EnableEvents = True

End Sub

As for your second question, I'm sorry but I do not understand the scenario you are describing.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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