Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic question on References

Status
Not open for further replies.

cfcanter

Technical User
Sep 12, 2001
31
US
I am using Reflections VBA but I think this is a general question in nature. Here is the code I am having problem's with:

If btnQTD Then

temp = Round(3.5) <-------- problem is this line here

thisweek = CInt(DateDiff(&quot;w&quot;, DateSerial(Year(Now()), 1, 1), Now(), vbSunday) / (1)) + 1
QtrStart = DateSerial(Year(Now()), 1, 1) + 7 - WeekDay(DateSerial(Year(Now()), 1, 1), 1) + (13 * 7)
End If

I am trying to find the starting day of the fiscal quarter based on an accouting calendar.

According to the object browser, &quot;Round&quot; and &quot;RoundUp&quot; are Excel functions. I have referenced the Microsoft Excel 9.0 Object Library. However, when I compile the program, I get a &quot;Sub or Function not defined&quot; error for the formula &quot;Round(xx)&quot;.

Can anyone explain what I am doing wrong?

thanks
c2
San Jose, CA Craig Canter
Cost Accountant
Sipex
Milpitas, CA
 
It looks ok to me, but since it's not working you could try using the full syntax for the round function.
variable = Round(Number, Number of decimal digits to use)

temp = Round(3.5, 0)
 
c2,

My 2¢. In MS Office VBA, there is a built-in Round function. Also, Excel provides Round, RoundUp and RoundDown worksheet functions, as noted. If I'm working in Excel VBA and wanted to use the worksheet version of the Round function I would have to use syntax similar to:

Code:
temp = Application.Round(3.2,0)

You may need to reference these functions in this manner.

HTH
M. Smith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top