View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Andrew Taylor Andrew Taylor is offline
external usenet poster
 
Posts: 225
Default Need help with codes please

I would guess that chkID is not defined in the context that
you are using it in. If the code is in a module (or is code-behind for
a worksheet) and the checkbox is on a form then you would need
to qualify the name it with the name of the form it's on - e.g.
UserForm1.chkID

If this is right, it would also help you if you had Option Explicit
at the top of the module - this would pick up the fact that you
were using an undefined vraible.




ernie wrote:

Hello

I get an error with my code below. when i put in "chkID.value = false", it
tells me object is required. but if i leave it as "chkID = false", it doesnt
recognise the check on the checkbox. what am i doing wrong?

Sub UpdateCPC()
If chkID.Value = False Then
ActiveCell.Offset(0, 1).Value = "0"
Else
ActiveCell.Offset(0, 1).Value = "1"
End If

If chkESC.Value = False Then
ActiveCell.Offset(0, 2).Value = "0"
Else
ActiveCell.Offset(0, 2).Value = "1"
End If

If chkCSC.Value = False Then
ActiveCell.Offset(0, 3).Value = "0"
Else
ActiveCell.Offset(0, 3).Value = "1"
End If

If chkET.Value = False Then
ActiveCell.Offset(0, 4).Value = "0"
Else
ActiveCell.Offset(0, 4).Value = "1"
End If

If chkVAT.Value = False Then
ActiveCell.Offset(0, 5).Value = "0"
Else
ActiveCell.Offset(0, 5).Value = "1"
End If

End Sub