Hi,
I tried out a workbook that was created in Excel 2007 on a laptop with Excel 2010. On the Excel 2010 machine, the ActiveX controls, two CommandButtons and a multicolumn Listbox no longer worked correctly.
Since I need this to work on both platforms, I decided to change from ActiveX controls to Form controls.
The CommandButtons worked just fine; just had to change from CommandButton to Button and that was it.
The Forms ListBox is still called a ListBox, but I receive an error when the code is run. The ActiveX and Forms control code are shown below.
ActiveX:
Forms:
The code is virtually identical however, I get an error that "variable not declared and the debugger points to:
Does anyone in the Forum have an idea make this work?
Thanks,
Art
I tried out a workbook that was created in Excel 2007 on a laptop with Excel 2010. On the Excel 2010 machine, the ActiveX controls, two CommandButtons and a multicolumn Listbox no longer worked correctly.
Since I need this to work on both platforms, I decided to change from ActiveX controls to Form controls.
The CommandButtons worked just fine; just had to change from CommandButton to Button and that was it.
The Forms ListBox is still called a ListBox, but I receive an error when the code is run. The ActiveX and Forms control code are shown below.
ActiveX:
Code:
Private Sub CommandButton2_Click()
Dim lbtarget As msforms.ListBox
Dim rngSource As Range
'Set reference to the range of data to be filled
Set rngSource = Worksheets("Chart").Range("O2:P50")
'Fill the listbox
Set lbtarget = ListBox1
With lbtarget
'Determine number of columns
.ColumnCount = 2
'Set column widths
.ColumnWidths = "40;20"
'Insert the range of data supplied
.List = rngSource.Cells.Value
End With
Forms:
Code:
Private Sub Button2_Click()
Dim lbtarget As msforms.ListBox
Dim rngSource As Range
'Set reference to the range of data to be filled
Set rngSource = Worksheets("Chart").Range("O2:P50")
'Fill the listbox
Set lbtarget = ListBox88
With lbtarget
'Determine number of columns
.ColumnCount = 2
'Set column widths
.ColumnWidths = "40;20"
'Insert the range of data supplied
.List = rngSource.Cells.Value
End With
End Sub
The code is virtually identical however, I get an error that "variable not declared and the debugger points to:
Code:
Set lbtarget = ListBox88
Does anyone in the Forum have an idea make this work?
Thanks,
Art