checkbox1 value = true if range got data

  • Thread starter Thread starter pswanie
  • Start date Start date
P

pswanie

i got a checkbox1 on a userform

column n down i got dates for this month 1 thru 31

checkbox1 needs be value = true if data next to todays date are enterd
allready.

and
if checkbox1 value = true then textbox1.enable = false
 
There are only 29 days in this month. :) These are valid dates, not just
numbers from 1 to 31 (29) with a month for a header?

Mike F
 
Try some code like the following:

Dim R As Range
Dim B As Boolean
For Each R In Worksheets("Sheet1").Range("D1:D31") '<<< CHANGE AS NEEDED
If Int(R.Value) = Int(Now) Then
If R(1, 2).Value <> vbNullString Then
B = True
End If
Exit For
End If
Next R

If B = True Then
CheckBox1.Value = True
TextBox1.Enabled = False
End If


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
where would i put this code? i tried it under a commandbutton1_click and
userform initialize

(and yip if feb got 28 days then we just ignore the first to days of march
etc)
 
where would i put this code? i tried it under a commandbutton1_click and
userform initialize

The code can go anywhere you want, really. Did it not work when it was
attached to CommandButton1? What error(s) did you get?


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
I have a feeling that the column just has numbers, not datesso the line of code: If Int(R.Value) = Int(Now) Then
would be comparing 6 to 2/6/2008 for today and not finding a match.

pswanie, you should put actual dates in each cell, ie 2/1/2008 for February
1, 2008 (unless you use European dates)
and you can drag that cell down to the end of Feb.

Mike F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top