Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 27
Default 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?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default 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?

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
no worksheets in a workbook - Excel 2003 Jarek Kujawa[_2_] Excel Discussion (Misc queries) 1 March 25th 09 11:38 AM
Alternative for =countifs (in 2007) for Excel 2003 Longhag Excel Discussion (Misc queries) 1 September 9th 08 03:28 PM
I need alternative formula for SUMIFS in Excel 2003 Jerome[_3_] Excel Worksheet Functions 3 June 10th 08 02:22 AM
How do I combine two worksheets in EXCEL 2003 Robert Judge Excel Discussion (Misc queries) 4 February 7th 08 01:48 PM
Excel 2003 Worksheets Bowtie63 Excel Discussion (Misc queries) 2 October 3rd 07 03:24 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"