Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
As a database developer, I sometimes help people convert their data from Excel into
Access. Although both applications can store data in a table format, they are built for
different purposes. Excel is a little bit easier to learn so a lot of people tend to use it
first. Eventually, when the data gets bigger or more complicated for Excel, they find it is
time to migrate their application into Access. Access is a lot better in handling relational
data than Excel. However, Excel users sometimes find it frustrating when they realize
some of the functions they typically use in Excel are not available in Access.
If you have not tried it before, creating a custom function in Access to mimic the
functionality of the NETWORKDAYS() Excel function is not easy. There are a number
of Access NETWORKDAYS() code examples available online. As it turns out, creating
a duplicate Excel function in Access is not always necessary. We can execute some
Excel functions through automation. The following code example shows how we can
execute the Excel NETWOKDAYS() function from within Access.
Dim xl As Object
Set xl = CreateObject("Excel.Application")
NetWorkdays = xl.WorksheetFunction.NETWORKDAYS(Format(StartDate,
"yyyy-mm-dd"), _
Format(EndDate, "yyyy-mm-dd"))
Set xl = Nothing
End Function
What the above code does is instantiate an Excel object and then use the
WorksheetFunction method to execute the Excel NETWORKDAYS() function.
Users can use this technique to execute some built-in Excel functions if they can't find
an equivalent Access function to do the same thing. I hope you find it useful.
Los usuarios pueden usar esta técnica para ejecutar algunas funciones
integradas de Excel si no pueden encontrar una función de acceso
equivalente para hacer lo mismo. Espero que le sea útil.