Sunday, 7 August 2016

Excel VBA Insert/delete Row in Sheet

I have an Excel Workbook for Inventory tracking and can't seem to make it work just as I need it. I have a Master Sheet with the Product and then Multiple Sheets for Warehouse locations. I would like to be able to add a new row in my master sheet and update the other sheets with the new product. I tried to write a VB Script to copy the part number from master to warehouse main and then populate the list with vlookup. I chose this approach so that when I change the description in master it would update all the sheets. I can't seem to be able to write a VB script that inserts a row where I want it to and do the same in my other sheets.




Here is an example:



enter image description here



Code I used to add rows from Master to Sub-sheet:







Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
For a = 1 To 10
Sheets("Master").Rows(a).Copy
Sheets("VBtest").Rows(a).Insert Shift:=xlDown
Next a
Application.ScreenUpdating = True
End Sub




Problem is it removes all my stock information. Just trying to add blank row and copy part number in first cell of row doesn't seem to work for me.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...