excel - How do I specify a path in the worksheet.add command? -
i'm relatively new programming in vba. want insert template worksheets. have code right works first step:
private sub workbook_sheetchange(byval sh object, byval target range) if target.column = 2 or 3 or 4 or 5 worksheets.add after:=worksheets(worksheets.count) worksheets(worksheets.count).name = target end if end sub
i know if want insert template these steps: expression: .add(before, after, count, type)
type specifies sheet type. can 1 of following xlsheettype constants: xlworksheet, xlchart, xlexcel4macrosheet, or xlexcel4intlmacrosheet. if inserting sheet based on existing template, specify path template. default value xlworksheet.
i need link type projectonderdelen.xltm, located in c:\users\stage\documents\aangepaste office-sjablonen
can me agony please?
greetings, brendon
if target.column = 2 or 3 or 4 or 5 then
not correct syntx.
either use:
if target.column = 2 or target.column = 3 or target.column = 4 or target.column = 5
or, switch select case
,which allows more versatility in future add more scenarios
select case target.column case 2 5 worksheets.add after:=worksheets(worksheets.count) worksheets(worksheets.count).name = target.value end select
Comments
Post a Comment