View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.newusers
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Trying to select a specific range based on the time value of u

The workbook really would help - it's a pretty busy form you have there,
taking some time just to build it to even get ready to test.

But one thing I noticed during that process is your Case statements - they
are specific in looking for a match to a specific date. In order to work on
any other day then you're going to have to modify the way the test values are
obtained. Probably going to involve setting up a value to get the current
date and adding the times to it, or stripping off the date and examining the
hour:minute portion only.

JLatham

"Jitranijam" wrote:

Thank you, the msgbox idea helped me see what the code was looking at.
So now it sets the appointment time by the WhatRowOffset, set up in the
Case Is statement, but the rest of the information is still set
according to the first row that is empty. I need the information to
stay together on one row. Is there something else I need to do to let
my program know to set focus on the offset row?

Here is my entire code, I do appreciate your suggestions as I am a
fairly new VBA programmer. I have been trying to teach myself by
books, unfortunately the books have not helped with this that much yet.
I thank you for any and all help you have and will give me.
************************************************** ************************************************** ******

Private Sub cboZipCode_Change()
If cboZipCode.Value = "" Then
txtZipCode.Enabled = False
End If
End Sub
----------------------------------------------------------------------
Private Sub chkOtherZip_Click()
If chkOtherZip = True Then
txtZipCode.Enabled = True
Else
txtZipCode.BackColor = &H80000004
End If
If chkOtherZip = False Then
txtZipCode.Enabled = False
Else
txtZipCode.BackColor = &H80000005
End If
End Sub
---------------------------------------------------------------------
Private Sub txtZipCode_Change()
If chkOtherZip = True Then
txtZipCode.Enabled = True
Else
txtZipCode.BackColor = &H80000004
End If

If chkOtherZip = False Then
txtZipCode.Enabled = False
Else
txtZipCode.BackColor = &H80000005
End If
End Sub
-------------------------------------------------------------------
Private Sub cmdClear_Click()
Call UserForm_Initialize
End Sub
------------------------------------------------------------------
Private Sub cmdCancel_Click()
Unload Me
End Sub
-------------------------------------------------------------------
Private Sub cmdOK_Click()
Range("A1").Select
ActiveWorkbook.Save
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
strClientName = txtClientName.Value
Select Case pckApptTime.Value
Case Is = "9/25/2006 7:00 AM"
WhatRowOffset = 0
Case Is = "9/25/2006 7:15 AM"
WhatRowOffset = 0
Case Is = "9/25/2006 8:00 AM"
WhatRowOffset = 9
Case Is = "9/25/2006 8:30:00 AM"
WhatRowOffset = 9
Case Is = "9/25/2006 9:00 AM"
WhatRowOffset = 19
Case Is = "9/25/2006 9:45 AM"
WhatRowOffset = 19
Case Is = "9/25/2006 10:00 AM"
WhatRowOffset = 29
Case Is = "9/25/2006 11:00 AM"
WhatRowOffset = 39
Case Is = "9/25/2006 1:00 PM"
WhatRowOffset = 0
Case Is = "9/25/2006 1:45 PM"
WhatRowOffset = 9
Case Is = "9/25/2006 3:15 PM"
WhatRowOffset = 49
Case Is = "9/25/2006 1:15 PM"
WhatRowOffset = 29
Case Is = "9/25/2006 2:30 PM"
WhatRowOffset = 39
Case Is = "9/25/2006 3:45 PM"
WhatRowOffset = 49
Case Else
MsgBox "Time: " & pckApptTime.Value & " Offset: " &
WhatRowOffset
End Select

ActiveCell.Offset(WhatRowOffset, 3) = pckApptTime.Value
ActiveCell.Value = StrConv(strClientName, vbProperCase)
ActiveCell.Offset(0, 1) = pckFDate.Value
ActiveCell.Offset(0, 2) = pckIntDate.Value
'ActiveCell.Offset(0, 3) = pckApptTime.Value

If chkYes1 = True Then
ActiveCell.Offset(0, 5).Value = "Yes"
End If
If chkNo1 = True Then
ActiveCell.Offset(0, 5).Value = "No"
End If
If ChkYes2 = True Then
ActiveCell.Offset(0, 6).Value = "Yes"
End If
If ChkNo2 = True Then
ActiveCell.Offset(0, 6).Value = "No"
End If
If chkPhone = True Then
ActiveCell.Offset(0, 7).Value = "X"
End If
If cboZipCode.Value = "" Then
ActiveCell.Offset(0, 8) = txtZipCode.Value
Else
ActiveCell.Offset(0, 8) = cboZipCode.Value
End If
If chkFS = True Then
ActiveCell.Offset(0, 9) = "X"
Else
ActiveCell.Offset(0, 9) = ""
End If
If chkMedical = True Then
ActiveCell.Offset(0, 10) = "X"
Else
ActiveCell.Offset(0, 10) = ""
End If
If ChkERDC = True Then
ActiveCell.Offset(0, 11) = "X"
Else
ActiveCell.Offset(0, 11) = ""
End If
If chkTANF = True Then
ActiveCell.Offset(0, 12) = "X"
Else
ActiveCell.Offset(0, 12) = ""
End If
If chkTADVS = True Then
ActiveCell.Offset(0, 13) = "X"
Else
ActiveCell.Offset(0, 13) = ""
End If
ActiveCell.Offset(0, 4) = cbowkrAssn.Value
ActiveCell.Offset(0, 15) = cboClerkInit.Value
ActiveCell.Offset(0, 16) = CboLanguage.Value

ActiveWorkbook.Save
End Sub
------------------------------------------------------------------------------
Private Sub cmdIntakeLog_Click()
Sheets("Monday Intake Log").Select
End Sub
------------------------------------------------------------------------------
Private Sub cmdMondayLog_Click()
Sheets("Monday Intake Log").Select
End Sub
--------------------------------------------------------------------------------
Private Sub cmdMondayRotation_Click()
Sheets("Monday").Select
Unload Me
End Sub
-----------------------------------------------------------------------------
Private Sub cmdTuesdayLog_Click()
Sheets("Tuesday Intake Log").Select
End Sub
----------------------------------------------------------------------------------
Private Sub cmdTuesdayRotation_Click()
Sheets("Tuesday").Select
Unload Me
End Sub
------------------------------------------------------------------------------------
Private Sub cmdWednesdayLog_Click()
Sheets("Wednesday Intake Log").Select
End Sub
----------------------------------------------------------------------------------------
Private Sub cmdWednesdayRotation_Click()
Sheets("Wednesday").Select
Unload Me
End Sub
--------------------------------------------------------------------------------------
Private Sub cmdThursdayLog_Click()
Sheets("Thursday Intake Log").Select
End Sub
-------------------------------------------------------------------------------------------
Private Sub cmdThursdayRotation_Click()
Sheets("Thursday").Select
Unload Me
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdFridayLog_Click()
Sheets("Friday Intake Log").Select
End Sub
-----------------------------------------------------------------------------------------
Private Sub cmdFridayRotation_Click()
Sheets("Friday").Select
Unload Me
End Sub
----------------------------------------------------------------------------------------------
Private Sub UserForm_Initialize()

ActiveWorkbook.Save
Range("A1").Select

txtClientName.Value = ""
chkFS = False
chkMedical = False
ChkERDC = False
chkTANF = False
chkTADVS = False

With cbowkrAssn
.AddItem "AH"
.AddItem "GB"
.AddItem "JB"
.AddItem "KC"
.AddItem "KM"
.AddItem "KT"
.AddItem "LO"
.AddItem "LR"
.AddItem "LS"
.AddItem "MO"
.AddItem "SD"
.AddItem "KW"
.AddItem "TW"
.AddItem "IJ"
.AddItem "EM"
.AddItem "NV"
.AddItem "KL"
.AddItem "AS"
End With

With CboLanguage
.AddItem "EN"
.AddItem "SP"
.AddItem "RU"
.AddItem "OTR"
End With

CboLanguage = ""
cbowkrAssn = ""
With cboClerkInit
.AddItem "DS"
.AddItem "DH"
.AddItem "RS"
.AddItem "KE"
.AddItem "JF"
.AddItem "MJ"
.AddItem "DB"
.AddItem "RV"
.AddItem "KV"
.AddItem "AT"
.AddItem "GJ"
.AddItem "MGR"
.AddItem "Lead"
.AddItem "Other"
End With

cboClerkInit = ""

With cboZipCode
.AddItem "97004"
.AddItem "97009"
.AddItem "97011"
.AddItem "97012"
.AddItem "97013"
.AddItem "97015"
.AddItem "97017"
.AddItem "97022"
.AddItem "97023"
.AddItem "97025"
.AddItem "97027"
.AddItem "97028"
.AddItem "97034"
.AddItem "97035"
.AddItem "97036"
.AddItem "97038"
.AddItem "97042"
.AddItem "97045"
.AddItem "97049"
.AddItem "97055"
.AddItem "97062"
.AddItem "97067"
.AddItem "97068"
.AddItem "97069"
.AddItem "97070"
.AddItem "97071"
.AddItem "97073"
.AddItem "97086"
.AddItem "97222"
.AddItem "97236"
.AddItem "97266"
.AddItem "97267"
.AddItem "97268"
End With