R
ranswrt
I have problems with a worksheet with some buttons using the forms toolbar.
It was working fine with the buttons from the forms toolbar. I changed the
buttons to commandbutton from the control toolbar so I could make changes to
the properties. Since I made the change a lot of the code that was working
fine using the buttons doesn't run using the command button. With some help
I think the problem is that the ranges I am accessing are on a different
sheet than the command buttons are. The sheet that has the command buttons
is named 'Estimates'. The sheet that I am trying to access the named cell is
called 'Estimates DB". I am now having problems with the following procedure
that is called from another procedure which is called from a command button
on the 'Estimates' sheet.
Sub addcheckbox()
Dim a As String
Dim cboxname As Integer
Dim ycell As Range
Dim chk As Excel.CheckBox
Dim z As String
Dim num As Long
Dim estnum As Long
Dim est As String
Dim lnknum As Long
est = Range("currentestimate")
estnum = Range("estimatenumber")
num = Range("estnum")
With Sheets("Estimates DB")
Set ycell = .Range("estdblinkno")
lnknum = ycell.Offset(estnum, 0)
End With
MsgBox ("lnknum= " & lnknum)
Set ycell = Sheets("Estimates").Range("estno").Offset(num, 1)
Set chk = ycell.Parent.Checkboxes.Add(ycell.Left, ycell.Top, 0, ycell.Height)
chk.Height = ycell.Height - 1.5
chk.Characters.Text = ""
chk.Name = "Checkbox" & est & lnknum
z = Sheets("Estimates DB").Range("estdbcboxlnkcell").Offset(estnum, 0).address
z = "'Estimates DB'!" & z
chk.LinkedCell = z
chk.Visible = True
chk.Display3DShading = True
chk.Value = False
chk.OnAction = "updateestimatetotal"
End Sub
I keep getting 0 for the value for lnknum. I tried all the variations to
try and get the right value and I keep getting 0. Any ideas on why this
won't work?
Thanks
It was working fine with the buttons from the forms toolbar. I changed the
buttons to commandbutton from the control toolbar so I could make changes to
the properties. Since I made the change a lot of the code that was working
fine using the buttons doesn't run using the command button. With some help
I think the problem is that the ranges I am accessing are on a different
sheet than the command buttons are. The sheet that has the command buttons
is named 'Estimates'. The sheet that I am trying to access the named cell is
called 'Estimates DB". I am now having problems with the following procedure
that is called from another procedure which is called from a command button
on the 'Estimates' sheet.
Sub addcheckbox()
Dim a As String
Dim cboxname As Integer
Dim ycell As Range
Dim chk As Excel.CheckBox
Dim z As String
Dim num As Long
Dim estnum As Long
Dim est As String
Dim lnknum As Long
est = Range("currentestimate")
estnum = Range("estimatenumber")
num = Range("estnum")
With Sheets("Estimates DB")
Set ycell = .Range("estdblinkno")
lnknum = ycell.Offset(estnum, 0)
End With
MsgBox ("lnknum= " & lnknum)
Set ycell = Sheets("Estimates").Range("estno").Offset(num, 1)
Set chk = ycell.Parent.Checkboxes.Add(ycell.Left, ycell.Top, 0, ycell.Height)
chk.Height = ycell.Height - 1.5
chk.Characters.Text = ""
chk.Name = "Checkbox" & est & lnknum
z = Sheets("Estimates DB").Range("estdbcboxlnkcell").Offset(estnum, 0).address
z = "'Estimates DB'!" & z
chk.LinkedCell = z
chk.Visible = True
chk.Display3DShading = True
chk.Value = False
chk.OnAction = "updateestimatetotal"
End Sub
I keep getting 0 for the value for lnknum. I tried all the variations to
try and get the right value and I keep getting 0. Any ideas on why this
won't work?
Thanks