Excel 2003 - using VBA to post to alternative worksheets
I have a complicated macro which posts a series of entries to a
worksheet called "expenses" but I am sending a copy of some sheets of this workbook to all the staff for completion - but it does not include the worksheet "expenses" but it does include a blank worksheet called "expenses_new". My question is can I adapt this macro so that if the worksheet "expenses" exists then the macro will make all the entries in that worksheet - but if it does not exist then all the entries will be posted to "expenses_new". Basically what I would like to do is find the VBA coding as follows:- If worksheet "expenses" exists then post all entries to "expenses" ELSE post all entries to "expenses.new" Will this work and how do I code it Thanks BJ? |
Excel 2003 - using VBA to post to alternative worksheets
Use
Dim flag As Boolean flag = False For Each wksheet In Application.Worksheets If wksheet.Name = "expenses" Then flag = True Exit For End If Next wksheet If flag Then 'set output to expenses Else 'set output to expenses_new End If "BJ&theBear" wrote: I have a complicated macro which posts a series of entries to a worksheet called "expenses" but I am sending a copy of some sheets of this workbook to all the staff for completion - but it does not include the worksheet "expenses" but it does include a blank worksheet called "expenses_new". My question is can I adapt this macro so that if the worksheet "expenses" exists then the macro will make all the entries in that worksheet - but if it does not exist then all the entries will be posted to "expenses_new". Basically what I would like to do is find the VBA coding as follows:- If worksheet "expenses" exists then post all entries to "expenses" ELSE post all entries to "expenses.new" Will this work and how do I code it Thanks BJ? . |
All times are GMT +1. The time now is 02:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com