LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 347
Default Function Sub Procedure If Not Active Worksheet

I am trying to create an add-in with the following VBA code stored in it. It
references 2 ranges that have a list of dates for the networkdays function.
The macro doesn't work if it is not the active worksheet.

Public Function Busdays()
Dim Break As Date
Dim Recon As Date
Dim strAnswer As VbMsgBoxResult
strAnswer = MsgBox("Is this a xxx?", vbQuestion + vbYesNo, "Select Yes
for xxx, No for yyy")
If strAnswer = vbYes Then
Break = InputBox("Enter the date of the break")
Recon = InputBox("Enter the date of the recon")
Busdays = networkdays(Break, Recon,
Workbooks("busdays.xls").Worksheets("Sheet1").Rang e("XHolidays"))
Busdays = Busdays - 1
Else
Break = InputBox("Enter the date of the exception")
Recon = InputBox("Enter the date of the recon")
Busdays = networkdays(Break, Recon,
Workbooks("busdays.xls").Worksheets("Sheet1").Rang e("YHolidays"))
Busdays = Busdays - 1
End If
End Function
 
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
active cell address with worksheet function Stefi Excel Worksheet Functions 3 November 26th 07 03:23 PM
how to call a function procedure nathan Excel Programming 4 January 17th 06 06:56 PM
procedure/function calling raja Excel Programming 1 October 3rd 05 12:32 PM
Unable to set the active cell from within a VBA procedure HMS Excel Programming 1 December 7th 04 09:57 PM
Worksheet change sub procedure Grant Excel Programming 5 September 24th 04 01:44 AM


All times are GMT +1. The time now is 01:41 AM.

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

About Us

"It's about Microsoft Excel"