Excel 如何在vba中绘制具有已知列索引的图表
我试图创建一个简单的用户表单来绘制选定列的图形 到目前为止,我所做的工作如下面的代码所示:Excel 如何在vba中绘制具有已知列索引的图表,excel,vba,indexing,graph,charts,Excel,Vba,Indexing,Graph,Charts,我试图创建一个简单的用户表单来绘制选定列的图形 到目前为止,我所做的工作如下面的代码所示: Public Sub UserForm_Initialize() Dim Axis As Variant Dim Axis1 As Variant Axis = Rows(1).Value ' here I'm filling the Comboboxes with all the names in the 1st row ComboBox1.Column =
Public Sub UserForm_Initialize()
Dim Axis As Variant
Dim Axis1 As Variant
Axis = Rows(1).Value
' here I'm filling the Comboboxes with all the names in the 1st row
ComboBox1.Column = Axis
ComboBox2.Column = Axis
End Sub
图表应如下所示: 在将来,我还将添加更多的组合框,以便选择更多的轴进行打印 我感谢每一个回答/帮助和建议
.ListIndex
属性获取基于0的索引值。因此,在这种情况下,实际的列索引将是ComboBox1.ListIndex+1谢谢您的建议@Dhirendra我将按照您的建议更改用户。我只是一个初学者:)但我的实际问题是,如何用几个选定的列绘制一个图形仍然没有得到回答。如果你能给我一些建议,我将不胜感激。谢谢
Public Sub Plot_Click()
With Range("A1:ZZ1")
'Here I'm searching for the column index of the selected value in the first Combobox
Set rFind1 = .Find(What:=ComboBox1.Value, LookAt:=xlWhole, _
MatchCase:=False, SearchFormat:=False)
End With
Spalte1 = rFind1.Column
With Range("A1:ZZ1")
'Here I'm searching for the column index of the selected value in the second Combobox
Set rFind2 = .Find(What:=ComboBox2.Value, LookAt:=xlWhole, _
MatchCase:=False, SearchFormat:=False)
End With
Spalte2 = rFind2.Column
'somewhere here, I would like to plot a graph with the selected
'column indexes (Spalte1 and Spalte2)
End Sub
Private Sub Schliessen_Click()
'here I'm closing the userform
Unload Me
End Sub