Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Does a worksheet exist
When a worksheet is named and copied from one workbook to another workbook
via a macro, is it possible to check whether that worksheet name already exists and if so to paste over it and not make a new sheet, as in Worksheet Name (1)? -- n00b lookn for a handout |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Does a worksheet exist
You could...
But if you really want the new sheet in that other workbook, how about just deleting it first? Dim wksName as string dim testwks as worksheet wksname = activesheet.name application.displayalerts = false 'not "are you sure prompt" on error resume next 'in case it isn't there otherworkbook.worksheets(wksname).delete on error goto 0 application.displayalerts = true Then do the copy. Arnie wrote: When a worksheet is named and copied from one workbook to another workbook via a macro, is it possible to check whether that worksheet name already exists and if so to paste over it and not make a new sheet, as in Worksheet Name (1)? -- n00b lookn for a handout -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Does a worksheet exist
This does seem to be a much simpler solution! To clarify tho, did you intend
for this code to go into the workbook that the sheet is being copied FROM or TO? Since you're using ActiveSheet I'm guess it should go in the FROM workbook, which means I would need to move my macro with the OnTime function there as well? -- n00b lookn for a handout "Dave Peterson" wrote: You could... But if you really want the new sheet in that other workbook, how about just deleting it first? Dim wksName as string dim testwks as worksheet wksname = activesheet.name application.displayalerts = false 'not "are you sure prompt" on error resume next 'in case it isn't there otherworkbook.worksheets(wksname).delete on error goto 0 application.displayalerts = true Then do the copy. Arnie wrote: When a worksheet is named and copied from one workbook to another workbook via a macro, is it possible to check whether that worksheet name already exists and if so to paste over it and not make a new sheet, as in Worksheet Name (1)? -- n00b lookn for a handout -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist | Excel Programming | |||
File opens as worksheet.xls:1 and worksheet.xls:2. Only one exist | Excel Programming | |||
Does a worksheet exist? | Excel Programming | |||
Does a worksheet exist | Excel Programming | |||
Does worksheet exist | Excel Programming |