check boxes in Excel - VBA Question

K

kblount.epsilon

I am attempting to have Excel change a formula based on the status of a
check box contained on a sheet. The code I have is the following:

Private Sub CheckBoxFULL_Change()

Application.ScreenUpdating = False

Select Case CheckBoxFULL.Value

Case True

Sheets("CAL-SHEET").Select
Range("F36").Select
ActiveCell.FormulaR1C1 = "='Line Fit FULL CURVE'!RC[-4]"
Worksheets("Line Fit FULL CURVE").Activate
Range("B36").Select

Case False

Sheets("CAL-SHEET").Select
Range("F36").Select
ActiveCell.FormulaR1C1 = "=R[-23]C[24]"
Worksheets("Line Fit FULL CURVE").Activate
Range("B36").Select

End Select

Sheets("CAL-SHEET").Select

Application.ScreenUpdating = True

End Sub

But I keep getting:

Run-time error '1004'
Select method of Range class failed

on the "Range("F36").Select" line. Why is this not functioning
correctly? If I copy the code to a plain macro, it performs everything
correctly, but when running it as I do above, it errors out.

Thanks for any help/guidance!

Ken
 
G

Guest

Private Sub CheckBoxFULL_Change()



Select Case CheckBoxFULL.Value

Case True

With Sheets("CAL-SHEET")
.Range("F36").FormulaR1C1 = _
"='Line Fit FULL CURVE'!RC[-4]"
End With

Case False

With Sheets("CAL-SHEET")
.Range("F36").FormulaR1C1 = _
"=R[-23]C[24]"

End Select

Worksheets("Line Fit FULL CURVE")
Worksheets("Line Fit FULL CURVE").Range("B36").Select



End Sub
 

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

Top