Textboxes on my UserForm are not dimmed when disabled

sbendbuckeye

Active Member
Joined
Nov 26, 2003
Messages
440
I have an Excel UserForm with 2 textboxes on it, txtBegDate and txtEndDate. For monthly or semimonthly payrolls they contain the day or days when payroll is processed (eg 1 and 15, 15 and EOM or just 15 for monthly, etc.). If the payroll is weekly then the textboxes need to be dimmed.

In the after update event for the ListBox which allows the user to select the payroll code I have logic similar to this:

txtBegDate.Enabled = IsMonthlyPayroll or IsSemiMonthlyPayroll

The Is functions are boolean and return True or False. Even thougth they are not greyed out they appear to be locked as you cannot give them focus or enter data into them. I'm using ExcelXP if that makes a difference.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hi sbendbuckeye,
Give this a shot. I think it'll work for what you want.
Might be a better / quicker way but it works for me.
(I'm using xl 2000 though, so...)
Code:
Private Sub DimmedTextBoxTest()
If Not MonthlyPayroll Then
    If Not SemiMonthlyPayroll Then
txtBegDate.Enabled = False
txtBegDate.BackColor = &H8000000F
Else:
txtBegDate.Enabled = True
End If
End If
End Sub

You can choose the background color you want by looking at what's offered in the textbox background color properties.

This work in xp?
Dan
 

sbendbuckeye

Active Member
Joined
Nov 26, 2003
Messages
440
Thanks,

It worked like a charm. I added the following line to set the background color back to white if it was reenabled:

txtBegDate.BackColor = &HFFFFFF
 

Watch MrExcel Video

Forum statistics

Threads
1,132,801
Messages
5,655,374
Members
418,193
Latest member
RichKatzRich

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top