Is it possible to insert rows based on criteria?

isaacv22

New Member
Joined
Sep 30, 2021
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm currently looking to see if it's possible to have a spreadsheet automatically insert (x) rows below based on answering a question?

For instances while filling a cell it'll ask me if this a multi track conveyor y or n?

If Y then it'd ask how many tracks? I'd be able to input a number and it'd add that many rows below.

Is this possible?

Thanks,

Isaac Vasquez
 
Hi Guys,

I'm currently trying to create a command button that would insert rows below a selected cell based on a criteria. For instance, you select a cell in column C and push the command button. An input message will ask you "how many tracks does this conveyor have? 1-12" The amount of rows inserted below would depend on the value you input, but I would like to include the selected cell as part of that count.

SAP Autofill Ver_2.1.xlsm
ACFH
1Column1Column3Column6Column8
2ConveyorTrackMaster TagTrack Length
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Formula Sheet
Cells with Data Validation
CellAllowCriteria
F4:F25List=validation_list


Thanks,

Isaac Vasquez
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Do you mean that if you select 1 row, then no rows are inserted?
SAP Autofill Ver_2.1.xlsm
ACF
1Column1Multiple TracksColumn6
2ConveyorTrackMaster Tag
4Conveyor 1
5Conveyor 2
6Conveyor 3
7Conveyor 4
8Conveyor 5
9Conveyor 6
10Conveyor 7
11Conveyor 8
12Conveyor 9
13Conveyor 10
Formula Sheet
Cells with Data Validation
CellAllowCriteria
F4:F13List=validation_list


To further elabortate, when entering data I would like to be able to have the Multiple Tracks button be able to inert x amount of rows based on a criteria. For instance if I were to select the red highlighted cell and the push the multiple tracks button on top of column C, an input message would ask "how many tracks does this conveyor have? 2-12" If I were to input 3 then it would count the from the selected cell and insert two rows below while auto numbering the rows 1-3. Not sure if this helps?
 
Upvote 0
How about
VBA Code:
Sub isaacv()
   Dim Rws As Variant
   
   Rws = InputBox("How many rows do you want?")
   If Rws = "" Then Exit Sub
   If Rws > 1 Then ActiveCell.Offset(1).Resize(Rws - 1).EntireRow.Insert
End Sub
 
Upvote 0
Works great! How would I go about having it auto number the rows? If not possible then no worries, I really appreciate your help!
 
Upvote 0
Ok, how about
VBA Code:
Sub isaacv()
   Dim Rws As Variant
   
   Rws = InputBox("How many rows do you want?")
   If Rws = "" Then Exit Sub
   If Rws > 1 Then
      ActiveCell.Offset(1).Resize(Rws - 1).EntireRow.Insert
      Range("C" & ActiveCell.Row).Resize(Rws).Value = Evaluate("""Conveyor "" & row(1:" & Rws & ")")
   End If
End Sub
 
Upvote 0
How is this question different than what you asked here?
 
Upvote 0
Ok, how about
VBA Code:
Sub isaacv()
   Dim Rws As Variant
  
   Rws = InputBox("How many rows do you want?")
   If Rws = "" Then Exit Sub
   If Rws > 1 Then
      ActiveCell.Offset(1).Resize(Rws - 1).EntireRow.Insert
      Range("C" & ActiveCell.Row).Resize(Rws).Value = Evaluate("""Conveyor "" & row(1:" & Rws & ")")
   End If
End Sub
This works, thank you very much. Kind of a long shot but would it be possible to have the value of the cells on the left and right copied and pasted down or would I have to create another macro for that?

Thanks!

Isaac Vasquez
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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