Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can anyone tell me why the following code cannot work in Function but ok in
a Sub? In Function, the statement Workbooks("testing.xls").Activate doesn't work, but ok in Sub Thanks Function no_of_HK_working_day(date1 As Date, date2 As Date, half_sat As Double) Set wb_current = ActiveWorkbook Workbooks("testing.xls").Activate Set wb_holiday = ActiveWorkbook wb_current.Activate End Function |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you mean running that function from a worksheet? If so, it is because
worksheet functions cannot make changes to the workbook or worksheets other than returning a value to that cell. If you ran that function from within VBA, it should work okay. -- HTH RP (remove nothere from the email address if mailing direct) "new.microsoft.com" wrote in message ... Can anyone tell me why the following code cannot work in Function but ok in a Sub? In Function, the statement Workbooks("testing.xls").Activate doesn't work, but ok in Sub Thanks Function no_of_HK_working_day(date1 As Date, date2 As Date, half_sat As Double) Set wb_current = ActiveWorkbook Workbooks("testing.xls").Activate Set wb_holiday = ActiveWorkbook wb_current.Activate End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why won't this function work? | Excel Worksheet Functions | |||
Function doesn't work | Excel Worksheet Functions | |||
need a function that will work using multiple work books and sheet | Excel Worksheet Functions | |||
Why does my Function not work? | Excel Discussion (Misc queries) | |||
function doesn't work | Excel Programming |