PDA

View Full Version : Duplicate the sheet and updte the Master



nsundarv
09-20-2019, 10:45 PM
Dear Friends,

Please help me in achieving this task

1. I have Country Master
2. I have Product Master
3. When ever New Country is added existing any one of the Country sheet should be duplicated and rename to the new country name
4. Then Product Master should be updated in New Country sheet
5. The same way when New Product is added that should updated in all the country sheet below the existing last item

Thanks,
Sundarvelan

SamT
09-21-2019, 08:03 AM
Worksheets are Excel Objects. Objects can have custom Properties. Add to the top of each Country sheet's codepage:
Option Explicit

Property Get SheetType() As String
SheetType = "Country"
End PropertyAny sheet can have any SheetType. Ie. "Products," "Prices," "etc." The Property code structure remains the same for all sheet types. Only the String changes.

Create a Country sheet Template, including any existing products in its List. include SheetType "Country" on its codepage.
Use a macro with an InputBox to get the new Country Name and copy the Country sheet Template.

Use a Macro to add the new Product info to all "Country" Sheets.

Dim Sht As Worksheet

For Each Sht in Sheets
If Sht.SheetType = "Country" Then
'Add your code to copy Product info to Sht here
End If
next

Good luck.

Au revoir.

nsundarv
09-21-2019, 05:49 PM
Dear Friend,

Since I'm new to vba, notable to understand.

Please help.