ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checkbox1 value = true if range got data (https://www.excelbanter.com/excel-programming/405564-checkbox1-value-%3D-true-if-range-got-data.html)

pswanie

checkbox1 value = true if range got data
 
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

Mike Fogleman

checkbox1 value = true if range got data
 
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
"pswanie" wrote in message
...
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




Chip Pearson

checkbox1 value = true if range got data
 
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)


"pswanie" wrote in message
...
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



pswanie

checkbox1 value = true if range got data
 
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)

"Chip Pearson" wrote:

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)


"pswanie" wrote in message
...
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



Chip Pearson

checkbox1 value = true if range got data
 
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)



"pswanie" wrote in message
...
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)

"Chip Pearson" wrote:

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)


"pswanie" wrote in message
...
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




Mike Fogleman

checkbox1 value = true if range got data
 
I have a feeling that the column just has numbers, not dates
(and yip if feb got 28 days then we just ignore the first to days of
march
etc)

so 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
"Chip Pearson" wrote in message
...
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)



"pswanie" wrote in message
...
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)

"Chip Pearson" wrote:

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)


"pswanie" wrote in message
...
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






All times are GMT +1. The time now is 08:20 AM.

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