Checkbox question

  • Thread starter Thread starter Patrick Simonds
  • Start date Start date
P

Patrick Simonds

On my userform initialize code, I want to have the checkbox value to be true
(checked) if there is something in the referenced cell. I populate my
textboxes with:

TextBox5.Text = rng(1, 2).Value

but not sure how to do this with a checkbox.
 
Maybe something like:

Option Explicit
Private Sub UserForm_Initialize()
Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <> "")
End Sub
 
I can not reference a set cell, it will always go to the same column, but
the row will be determined by which row the curser is on. That is why I was
trying the rng(1, 2). For this Checkbox it will always look at column 2 of
the current row.
 
I should mention that I use the following to define rng:

Dim rng
Set rng = Cells(ActiveCell.Row, 1)


Patrick Simonds said:
I can not reference a set cell, it will always go to the same column, but
the row will be determined by which row the curser is on. That is why I
was trying the rng(1, 2). For this Checkbox it will always look at column
2 of the current row.
 
Try Daves solution with these modifications:

Option Explicit
Public rng As Range
Private Sub UserForm_Initialize()
Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range(rng).Value <> "")
End Sub

Mike F

Patrick Simonds said:
I should mention that I use the following to define rng:

Dim rng
Set rng = Cells(ActiveCell.Row, 1)
 
or maybe:


Option Explicit
Private Sub UserForm_Initialize()
dim rng as range
Set rng = activesheet.Cells(ActiveCell.Row, 1)
Me.CheckBox1.Value = CBool(rng(1,2).Value <> "")
End Sub



Patrick said:
I should mention that I use the following to define rng:

Dim rng
Set rng = Cells(ActiveCell.Row, 1)
 
I want to thank you all, Me.CheckBox1.Value = CBool(rng(1,2).Value <> "")
was what it took to make this work.
 

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

Back
Top