X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Properly Using References    
post Jul 29 2002, 12:43 PM

Posts: 319
Joined: 9-February 00
From: Elgin, IL

This problem is actually in Reflections VBA but I think it is generic in nature. Here is the code I am having trouble with:
If btnQTD Then
temp = RoundUp(3.5) <------------ this is the problem
thisweek = CInt(DateDiff("w", 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 want to use Excel's RoundUp function. According to the object browser it is in the Excel Library as a Worksheet function.
I have referenced Microsoft Excel 9.0 Object Library. However, the "RoundUp" line gives me a "Sub or Function is not defined error."
Would somebody explain what I am doing incorrectly?
san jose, CA
Go to the top of the page
post Jul 29 2002, 01:28 PM

Posts: 1,114
Joined: 8-February 02
From: California, USA

Dim sngTemp As Single
sngTemp = Application.WorksheetFunction.RoundUp(3.57, 1)
MsgBox sngTemp
Owent ahead and declared the variable as a single so that it would support decimals, unless you want integers.
To use a worksheet function, you need to specify "application.worksheetfunction." before the function. The RoundUp function also requires 2 arguments, the number being rounded and the # of decimal places you want to round to. If you want to round to whole numbers, you would use roundup(3.5,0).
Hope this helps!
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    16th July 2019 - 10:05 PM