ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   floor and rounding (https://www.excelbanter.com/excel-programming/360718-floor-rounding.html)

srroduin

floor and rounding
 
I thought I had it after reading all of the other posts and links.

The user will put in a date and time in the input box. I need to round any
minutes down to the previous hour. Finally I need to add 1 hour to that
time. What am I doing wrong?

I went into tools references and added atpvbaen. Everytime I run it it says
function or sub not defined and floor is highlighted. Help!!!

So far I have this:

SASStart = InputBox("Enter start date mm/dd/yyyy hh:mm of event, USE CLOCK
TIME")

SASStartRound = Time(Hour(SASStart), Floor(Minute(SASStart), 1), 0)

SASStartClock = DateAdd("h", 1, SASStartRound)


peter

floor and rounding
 
Hi,
try this...
sasstart = Now
sasstartround = Hour(sasstart) & ":" &
Application.WorksheetFunction.Floor(Minute(sasstar t), 1)
SASStartClock = DateAdd("h", 1, sasstartround)


"srroduin" wrote:

I thought I had it after reading all of the other posts and links.

The user will put in a date and time in the input box. I need to round any
minutes down to the previous hour. Finally I need to add 1 hour to that
time. What am I doing wrong?

I went into tools references and added atpvbaen. Everytime I run it it says
function or sub not defined and floor is highlighted. Help!!!

So far I have this:

SASStart = InputBox("Enter start date mm/dd/yyyy hh:mm of event, USE CLOCK
TIME")

SASStartRound = Time(Hour(SASStart), Floor(Minute(SASStart), 1), 0)

SASStartClock = DateAdd("h", 1, SASStartRound)


srroduin

floor and rounding
 
I'm finally able to try this again now that I have the rest of my code working.

When I did this it didn't change anything. The SASStart value is typed in
by the user and is used throughout the code so I didn't make it = to now.

For example 5/10/2006 08:14 stayed the same. ANY IDEAS???? Thanks for you
help!

"peter" wrote:

Hi,
try this...
sasstart = Now
sasstartround = Hour(sasstart) & ":" &
Application.WorksheetFunction.Floor(Minute(sasstar t), 1)
SASStartClock = DateAdd("h", 1, sasstartround)


"srroduin" wrote:

I thought I had it after reading all of the other posts and links.

The user will put in a date and time in the input box. I need to round any
minutes down to the previous hour. Finally I need to add 1 hour to that
time. What am I doing wrong?

I went into tools references and added atpvbaen. Everytime I run it it says
function or sub not defined and floor is highlighted. Help!!!

So far I have this:

SASStart = InputBox("Enter start date mm/dd/yyyy hh:mm of event, USE CLOCK
TIME")

SASStartRound = Time(Hour(SASStart), Floor(Minute(SASStart), 1), 0)

SASStartClock = DateAdd("h", 1, SASStartRound)


peter

floor and rounding
 
Hi,
It's not the "now" that matters. Any time will do. Take a look at the
application.worksheetfunction in order to get floor to work.

peter

"srroduin" wrote:

I'm finally able to try this again now that I have the rest of my code working.

When I did this it didn't change anything. The SASStart value is typed in
by the user and is used throughout the code so I didn't make it = to now.

For example 5/10/2006 08:14 stayed the same. ANY IDEAS???? Thanks for you
help!

"peter" wrote:

Hi,
try this...
sasstart = Now
sasstartround = Hour(sasstart) & ":" &
Application.WorksheetFunction.Floor(Minute(sasstar t), 1)
SASStartClock = DateAdd("h", 1, sasstartround)


"srroduin" wrote:

I thought I had it after reading all of the other posts and links.

The user will put in a date and time in the input box. I need to round any
minutes down to the previous hour. Finally I need to add 1 hour to that
time. What am I doing wrong?

I went into tools references and added atpvbaen. Everytime I run it it says
function or sub not defined and floor is highlighted. Help!!!

So far I have this:

SASStart = InputBox("Enter start date mm/dd/yyyy hh:mm of event, USE CLOCK
TIME")

SASStartRound = Time(Hour(SASStart), Floor(Minute(SASStart), 1), 0)

SASStartClock = DateAdd("h", 1, SASStartRound)



All times are GMT +1. The time now is 09:50 AM.

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