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 |
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 |
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 |
All times are GMT +1. The time now is 08:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com