Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Error using Application.WorksheetFunction

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cabaco - 22 Feb 2007 17:27 GMT
Hi,

I need your help!!!
I'm using MS Office Pro 2007 and in a VBA procedure I use a
Application.WorksheetFunction.VLookup.... that doesn't work - Just returns
error no 400. Am I missing any library?

Thanks.
Cabaco

Here is the procedure:

Sub ListSchedule()
'DEFINITIONS:
   Dim sShtData, sShtLayout As Worksheet
   Dim MyXlFunc As WorksheetFunction
   Dim lMes, lAno, lFunc1, lFunc9, lCountr As Long
   Dim rEmployees, rMonthTable, rWeekdays As Range
   Dim rMes, rAno, rPeriod As Range
   Dim rEmployeeName, rEmployeeNo, rEmployeeTest As Range
'DATA:
   Set MyXlFunc = Application.WorksheetFunction
   Set sShtData = Application.Worksheets("Funcion")
   Set sShtLayout = Application.Worksheets("FichaPonto")
   Set rEmployees = sShtData.Range("A1").CurrentRegion
   Set rMonthTable = sShtLayout.Range("X7:Y19")
   Set rWeekdays = sShtLayout.Range("X21:AA28")
   Set rMes = sShtLayout.Range("V3")
   Set rAno = sShtLayout.Range("V4")
   Set rPeriod = sShtLayout.Range("V2")
   Set rEmployeeName = sShtLayout.Range("E4")
   Set rEmployeeNo = sShtLayout.Range("P4")
   Set rEmployeeTest = sShtLayout.Range("U3")
   lMes = Month(Date)
   lAno = Year(Date)
   lCountr = 1
'RUN:
   lMes = InputBox("Mês:", "Indicar...", Month(Date))
   lAno = InputBox("Ano:", "Indicar...", Year(Date))
   lFunc1 = InputBox("Do funcionário:", "Parametros de impressão...")
   lFunc9 = InputBox("Ao funcionário:", "Parametros de impressão...")
   rMes.Value = lMes
   rAno.Value = lAno
   For lCountr = lFunc1 To lFunc9 Step 1
       rEmployeeNo.Value = lCountr
       rEmployeeTest.Value = MyXlFunc.VLookup(lCountr, rEmployees, 2, False)
       If rEmployeeTest.Value = 1 Then
           sShtLayout.PrintOut
       Else
       End If
   Next
'CLEAN:
   Set sShtData = Nothing
   Set sShtLayout = Nothing
   Set rEmployees = Nothing
   Set rMonths = Nothing
   Set rWeekdays = Nothing
   Set rMes = Nothing
   Set rAno = Nothing
   Set rPeriod = Nothing
   Set MyXlFunc = Nothing
   lMes = 0
   lAno = 0
   lFunc1 = 0
   lFunc9 = 0
   lCountr = 0
End Sub
Gary''s Student - 22 Feb 2007 17:59 GMT
You have lCount as Long and use it as a loop index.  Check to see if you need
a range.  for example

Set MyXlFunc = Application.WorksheetFunction
x = MyXlFunc.Sum(Range("A1:A10"))

will work

x=MyXlFunc.Sum(A1:A10)

does not
Signature

Gary''s Student
gsnu200707

> Hi,
>
[quoted text clipped - 63 lines]
>     lCountr = 0
> End Sub
Cabaco - 23 Feb 2007 13:42 GMT
Thanks for your answer,

lCountr is a number, an id, that that the function should look for in the
range rEmployees. Besides, I've tried to use other functions and they don't
work either.
Simply, I can't make the Application.WorksheetFunction work.

If you have any ideas, I'd appreciate.
Thanks,
Cabaco

> You have lCount as Long and use it as a loop index.  Check to see if you need
> a range.  for example
[quoted text clipped - 75 lines]
> >     lCountr = 0
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.