ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compile error - expected an array (https://www.excelbanter.com/excel-programming/373429-compile-error-expected-array.html)

John

compile error - expected an array
 
Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next

John

compile error - expected an array
 
didn't Dim my variable correctly :)

"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


Tom Ogilvy

compile error - expected an array
 
Next error - Workday isn't a worksheetfunction. It is in the Analysis
toolpak - VBA and should be called using application.Run (or if you have a
reference to that addin, call it like a builtin VBA function).

--
Regards,
Tom Ogilvy


"John" wrote:

didn't Dim my variable correctly :)

"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


Tom Ogilvy

compile error - expected an array
 
Public Type Material
MatNum As Integer
MatDate() As Date
End Type

Public matType() As Material

Const MaxMaterials As Long = 12
Sub ABCEFG()
ReDim matType(1 To MaxMaterials)
For i = 1 To MaxMaterials
ReDim matType(i).MatDate(1 To 10)
Next

End Sub

--
Regards,
Tom Ogilvy


"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


John

compile error - expected an array
 
thanks Tom...

For i = Dates.Count To 1 Step -1
DTadj(i) = (Application.Run.WORKDAY(Dates(i), 1, Holidays)) - Dates(i)
Next

this still doesn't work?

"Tom Ogilvy" wrote:

Next error - Workday isn't a worksheetfunction. It is in the Analysis
toolpak - VBA and should be called using application.Run (or if you have a
reference to that addin, call it like a builtin VBA function).

--
Regards,
Tom Ogilvy


"John" wrote:

didn't Dim my variable correctly :)

"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


John

compile error - expected an array
 
wow is that for my post? I am confused if it is..

"Tom Ogilvy" wrote:

Public Type Material
MatNum As Integer
MatDate() As Date
End Type

Public matType() As Material

Const MaxMaterials As Long = 12
Sub ABCEFG()
ReDim matType(1 To MaxMaterials)
For i = 1 To MaxMaterials
ReDim matType(i).MatDate(1 To 10)
Next

End Sub

--
Regards,
Tom Ogilvy


"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


Tom Ogilvy

compile error - expected an array
 
to demonstrate usage:

set Holidays = Range("A1:A10")
dt = application.Run("ATPVBAEN.XLA!Workday",date, 20, Holidays)
Msgbox format(dt,"mmm dd, yyyy")

Would show
Oct 19, 2006
if there are no holidays in between.

the other post was inadvertently posted there. It was for another thread.

--
Regards,
Tom Ogilvy


"John" wrote:

thanks Tom...

For i = Dates.Count To 1 Step -1
DTadj(i) = (Application.Run.WORKDAY(Dates(i), 1, Holidays)) - Dates(i)
Next

this still doesn't work?

"Tom Ogilvy" wrote:

Next error - Workday isn't a worksheetfunction. It is in the Analysis
toolpak - VBA and should be called using application.Run (or if you have a
reference to that addin, call it like a builtin VBA function).

--
Regards,
Tom Ogilvy


"John" wrote:

didn't Dim my variable correctly :)

"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


John

compile error - expected an array
 
THANKS TOM!!!!!

"Tom Ogilvy" wrote:

to demonstrate usage:

set Holidays = Range("A1:A10")
dt = application.Run("ATPVBAEN.XLA!Workday",date, 20, Holidays)
Msgbox format(dt,"mmm dd, yyyy")

Would show
Oct 19, 2006
if there are no holidays in between.

the other post was inadvertently posted there. It was for another thread.

--
Regards,
Tom Ogilvy


"John" wrote:

thanks Tom...

For i = Dates.Count To 1 Step -1
DTadj(i) = (Application.Run.WORKDAY(Dates(i), 1, Holidays)) - Dates(i)
Next

this still doesn't work?

"Tom Ogilvy" wrote:

Next error - Workday isn't a worksheetfunction. It is in the Analysis
toolpak - VBA and should be called using application.Run (or if you have a
reference to that addin, call it like a builtin VBA function).

--
Regards,
Tom Ogilvy


"John" wrote:

didn't Dim my variable correctly :)

"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


Dave Peterson

compile error - expected an array
 
It's for a different question.

John wrote:

wow is that for my post? I am confused if it is..

"Tom Ogilvy" wrote:

Public Type Material
MatNum As Integer
MatDate() As Date
End Type

Public matType() As Material

Const MaxMaterials As Long = 12
Sub ABCEFG()
ReDim matType(1 To MaxMaterials)
For i = 1 To MaxMaterials
ReDim matType(i).MatDate(1 To 10)
Next

End Sub

--
Regards,
Tom Ogilvy


"John" wrote:

Here is the code and I am getting a compile error...

any ideas?

For a = Dates.Count To 0 Step -1
DTadj(a) = Application.WorksheetFunction.workday(Dates(a), 1,
Holidays) - Dates(a)
Next


--

Dave Peterson


All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com