Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Date Validation via Combobox in VBA

Hi,

I have created a user form to update the balanaces in the accounts.
User can pick the dates, which are user can choose by a combox box and
update accordingly.

I want to have a validation check for the date so that the user are
not allowed to pick dates which have balances already attached to
them.

I tried creating the following but its not working. I am new to VBA so
if someone can help me move in the right direction that would be
really helpful.

---------------------------------------------------

Private Sub cmblist_Change()

DateCheck

End Sub

----------------------------------------------------

Private Sub DateCheck()


If cmblist.Value < Sheets("CDN").Range("DateDBCDN") Then

' DateDBCDN is the range where the dates are posted from the user
form.

msg = "Data for this date is already posted"
Sheets("Main").Select
Range("A2").Select
dialogstyle = vbOKOnly + vbCritical
Title = "Invalid Date"
Response = MsgBox(msg, dialogstyle, Title)

End If
End Sub

-----------------------------------------------------------------------

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Date Validation via Combobox in VBA

I'm confused. A ComboBox is for offering the user a prescribed set of
choices. A list of specific dates fits that. Yet you seem to want the
user to choose a date which is NOT in a prescribed set.

Also, your line:
If cmblist.Value < Sheets("CDN").Range("DateDBCDN") Then
can't work when the left side is a one value and the right side is
presumably several values. There are some computer languages with
which one can compare a scalar to a vector and get a vector answer.
Indeed, some Excel worksheet formulas allow that. However, VBA isn't
one of them.

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Date Validation via Combobox in VBA


Thanks for the reply.

What I am trying is to give user the combo box to pick up a date to
input the data.
Date is in a combo box and then data goes in separate boxes.

I dont want them to pick a date which has already data associated with
it or in otherwords the account balances for that date has already
been updated. Since its a combobox all the dates will show (my
understanding) but I want to put a warning message so if they pick a
already input date from combobox it should a warning message should
come up.

I am a beginner in VBA so I may be on the wrong track.

The code using cmblist.value, I m trying to check the combobox value
with a range in worksheet (A4:A365).

I hope I made my self clear this time.

Thanks for the help.

NM

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Date Validation via Combobox in VBA

If you are loading your combo box from a row source, you might consider
writing code to delete the used date from the row source as it is used. That
would leave only valid dates to select from. Without knowing how you load
the control, that is the best I can offer.

" wrote:


Thanks for the reply.

What I am trying is to give user the combo box to pick up a date to
input the data.
Date is in a combo box and then data goes in separate boxes.

I dont want them to pick a date which has already data associated with
it or in otherwords the account balances for that date has already
been updated. Since its a combobox all the dates will show (my
understanding) but I want to put a warning message so if they pick a
already input date from combobox it should a warning message should
come up.

I am a beginner in VBA so I may be on the wrong track.

The code using cmblist.value, I m trying to check the combobox value
with a range in worksheet (A4:A365).

I hope I made my self clear this time.

Thanks for the help.

NM


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Date Validation via Combobox in VBA

Yes I am loading the combobox from a row source.

I think that would be easier but then again if I delete the rows that
have been used, wouldnt it show a blank dropdown menu untill that date
is shown.

Naeem



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Date Validation via Combobox in VBA

It sounds like an InputBox, TextBox, Calendar control, or Monthview
control would be a better means. The first doesn't even need a
UserForm. If the latter two are not on your Toolbox (where you got the
ComboBox), right-click on the Toolbox, then click Additional Controls,
then check Calendar Control or Microsoft Monthview control.

Hth,
Merjet


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
width of ComboBox for data validation hstijnen Excel Discussion (Misc queries) 1 September 13th 07 01:57 PM
Combobox/data validation KneeDown2Up New Users to Excel 1 October 21st 06 01:55 PM
How to use validation formulas in Combobox GlenC Excel Discussion (Misc queries) 1 September 21st 06 10:19 PM
Combobox and data validation GlenC Excel Discussion (Misc queries) 2 September 13th 06 06:52 PM
data validation vs combobox paul Excel Discussion (Misc queries) 4 October 24th 05 11:42 PM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"