View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Combobox / Data Problems

if you can find the first date and the last date, then you could use something
like:

Option Explicit
Sub testme01()

Dim StartDate As Date
Dim AdjStartDate As Date
Dim LastDate As Date
Dim AdjLastDate As Date
Dim myDate As Date
Dim iCtr As Long

'I just started with what you gave me.
StartDate = DateSerial(2005, 8, 12) + TimeSerial(21, 41, 46)
LastDate = DateSerial(2005, 8, 12) + TimeSerial(21, 43, 46)

AdjStartDate = Int(StartDate) _
+ TimeSerial(Hour(StartDate), Minute(StartDate), 0)
AdjLastDate = Int(LastDate) _
+ TimeSerial(Hour(LastDate), Minute(LastDate), 0)

Worksheets("sheet1").ComboBox3.Clear

iCtr = -1
Do
iCtr = iCtr + 1 'start with 0
myDate = AdjStartDate + TimeSerial(0, iCtr, 0)
If myDate AdjLastDate Then
Exit Do
End If

Worksheets("sheet1").ComboBox3.AddItem _
Format(myDate, "mmmm dd, yyyy hh:mm:ss")
Loop

End Sub

I would think that you could use something like:

Startdate= application.min(worksheets("sheet99").range("a:a") )
Lastdate = application.max(worksheets("sheet99").range("a:a") )


maybe?????



Matt wrote:

it works nicely :)

Only problem some of my logic that detects for invalid dates seems to
kick in .. I had a Inumber in there ti prevent text input .. I may have
to take that out. But still have to prevent the user from entering a
not date ...

Something else I am thinking is that my data comes like that:

8/12/2004 21:41:46
8/12/2004 21:43:46
8/12/2004 21:45:46
8/12/2004 21:47:46
8/12/2004 21:49:46
8/12/2004 21:51:46
8/12/2004 21:53:46
8/12/2004 21:55:46
8/12/2004 21:57:46
8/12/2004 21:59:46
8/12/2004 22:01:46

The user essentially has to enter a date which I simplified by having
them select it from the combobox which shows all possible logged dates.

But they will never enteer anything else than 00 seconds. And they may
have to enter a minute that is in between the loggedones (it logs every
two minutes).

- Is there a way to populate the combox with additional dates?
- Also is there a way to alwyas have the seconds be 00? No mater what
the source data is like?

Existing Data:
8/12/2004 21:41:46
8/12/2004 21:43:46

I need it like this:

8/12/2004 21:41:00 (seconds changed to 00)
8/12/2004 21:42:00 (Entire date added)
8/12/2004 21:43:00 (seconds changed to 00)

:) Matt


--

Dave Peterson