ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkbox problem (https://www.excelbanter.com/excel-programming/368063-checkbox-problem.html)

WLMPilot

Checkbox problem
 
I am trying to use checkboxes that will place one of two values in a cell
based on the checkbox being TRUE/FALSE. The spreadsheet I have created
calculates my baseline annual salary. In doing so, I had to list the
holidays that the county recognizes. If I work that holiday, then I get paid
for 16 hours. Otherwise I get paid for 8 hours. The problem is that the
formula is not picking up the ELSE statement. The value placed in the cell
is 16, regardless of the checkbox being TRUE or FALSE.

The cells involved a
E23:E33 (name of holidays)
G23:G33 (value of hours worked - 8 or 16)
H23:H33 (placement of checkbox)

The formula that I created in the macro is:

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then Worksheets("Pay-Calc").Cells(23, 7).Value
= 16 Else Worksheets("Pay-Calc").Cells(23, 7).Value = 8
End Sub

NOTE: 1) The IF statement is on one line in the macro. 2) The appropriate
adjustments were made to reference the correct CHECKBOX and CELL - ie
CHECKBOX1 - CHECKBOX11 and CELLS(23,7) - CELLS(33,7)

Can anyone help me out with this?

Thanks,
Les

davesexcel[_124_]

Checkbox problem
 

If CheckBox1.Value = True Then
Worksheets("Sheet1").Cells(23, 7).Value = 16
Else: Worksheets("Sheet1").Cells(23, 7).Value = 8
End If


this seems to work for me


--
davesexcel


------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=564091



All times are GMT +1. The time now is 05:31 PM.

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