VBA to insert rows in sheet 2 (parts list) at row 5,& move existing datas down while inserting new rows,when drop down value is selected on E4 sheet1.

nscaria00

New Member
Joined
Apr 21, 2023
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I am trying to get VBA code to insert rows in sheet 2 (parts list) at row 5,& move existing data's down while inserting new rows, when drop down value is selected on E4 sheet1 (RFQ package).

also, if someone enters value on program life column and total volume on all new inserted rows (in sheet 2 Parts list), YR1-yr 10 can autopopulate based on enetered values (Total volume divide by program life)., that would be excellent.
 

Attachments

  • Sheet 1 (RFQ Package).JPG
    Sheet 1 (RFQ Package).JPG
    35.4 KB · Views: 8
  • Sheet 2 (Parts list).JPG
    Sheet 2 (Parts list).JPG
    68.7 KB · Views: 9

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Will new entries always be entered into row 4 on sheet 1? Or will other rows be used also?

Where does Customer Part # and Description info come from?
 
Upvote 0
Will new entries always be entered into row 4 on sheet 1? Or will other rows be used also?

Where does Customer Part # and Description info come from?
Yes, always new entry goes to row 4 on sheet 1.
Customer part # and Description is manually typed in, since that's comes through Customer portal. I don't know if I can convert a webpage to excel and pull data to populate in Customer part # and description.. May be that's too much..
 
Upvote 0
Okay, then perhaps this should get you what you want. Give it a try on a copy of your workbook (copy/paste in the sheet1 code module):
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRows As Long, i As Long, j As Long
Dim ws As Worksheet
Set ws = Sheets("parts list")
On Error Resume Next
Application.EnableEvents = False
If Not Intersect(Target, Range("E4")) Is Nothing Then
    iRows = 5 + Range("E4").Value - 1
    For i = 1 To Range("E4").Value
        j = i + 4
        ws.Range("A" & j & ":O" & j).Insert Shift:=xlDown
        ws.Range("A" & j).Value = Range("A4").Value
        ws.Range("F" & j & ":O" & j).Formula2 = "=IF(COLUMNS($F$5:F5)>$E" & j & ","""",$D" & j & "/$E" & j & ")"
    Next i
End If
Application.EnableEvents = True
End Sub

It inserts new rows into sheet 2 determined by the amount selected in E4 on sheet 1. It also enters a formula into the F:O columns to handle your second question.
 
Upvote 0
Solution
Okay, then perhaps this should get you what you want. Give it a try on a copy of your workbook (copy/paste in the sheet1 code module):
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRows As Long, i As Long, j As Long
Dim ws As Worksheet
Set ws = Sheets("parts list")
On Error Resume Next
Application.EnableEvents = False
If Not Intersect(Target, Range("E4")) Is Nothing Then
    iRows = 5 + Range("E4").Value - 1
    For i = 1 To Range("E4").Value
        j = i + 4
        ws.Range("A" & j & ":O" & j).Insert Shift:=xlDown
        ws.Range("A" & j).Value = Range("A4").Value
        ws.Range("F" & j & ":O" & j).Formula2 = "=IF(COLUMNS($F$5:F5)>$E" & j & ","""",$D" & j & "/$E" & j & ")"
    Next i
End If
Application.EnableEvents = True
End Sub

It inserts new rows into sheet 2 determined by the amount selected in E4 on sheet 1. It also enters a formula into the F:O columns to handle your second question.
Excellent, that works perfectly!
 
Upvote 0
One another help please. I have a master excel document which has couple of tabs (shown in tabs to extract image). I am populating data's in three tabs (component, tools and logistics) from other tabs by using "=" function. But I need to extract these three documents before I send to customer.
I am looking for a VBA code to extract these three tabs from master and create another document (with these three tabs) and save with RFQ number from "Pre-review checklist" B1 cell.
In the extracted files, "=" function should not be there and the datas needs to show as values (i mean not linked any more to master file). Is it doable?
I can share the excel document if needs to.
Thanks,
 

Attachments

  • each tab has some formulas that's linked to other tabs in master excel document.JPG
    each tab has some formulas that's linked to other tabs in master excel document.JPG
    90.8 KB · Views: 2
  • Extract button and RFQ number.JPG
    Extract button and RFQ number.JPG
    44.8 KB · Views: 3
  • tabs to extract.JPG
    tabs to extract.JPG
    23.8 KB · Views: 2
Upvote 0
One another help please. I have a master excel document which has couple of tabs (shown in tabs to extract image). I am populating data's in three tabs (component, tools and logistics) from other tabs by using "=" function. But I need to extract these three documents before I send to customer.
I am looking for a VBA code to extract these three tabs from master and create another document (with these three tabs) and save with RFQ number from "Pre-review checklist" B1 cell.
In the extracted files, "=" function should not be there and the datas needs to show as values (i mean not linked any more to master file). Is it doable?
I can share the excel document if needs to.
Thanks,
As this is a new question, you should post it in its own thread.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

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