Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 单元格中的数据太多,无法在Userform列表框中显示_Excel_Vba_Userform - Fatal编程技术网

Excel 单元格中的数据太多,无法在Userform列表框中显示

Excel 单元格中的数据太多,无法在Userform列表框中显示,excel,vba,userform,Excel,Vba,Userform,我在Excel2007的用户表单中有一个列表框 “我的工作表”中的某些单元格包含超过10行(使用ALT ENTER键输入数据) 我正在尝试清理和显示数据。我不想将列宽更改为1000,但我想使用鼠标悬停框来显示所有单元格数据 还有其他可行的方法吗?鼠标悬停可以实现,但我认为这很复杂。这里我有另一个更简单的想法:双击列表框,将显示一个包含所选列表项数据的多行文本框。此文本框的位置和大小与列表框相同。在用户窗体上,单击“隐藏文本框”。下面是一些示例代码,要测试它,您需要一个名为“ListBox1”的列

我在Excel2007的用户表单中有一个列表框

“我的工作表”中的某些单元格包含超过10行(使用ALT ENTER键输入数据)

我正在尝试清理和显示数据。我不想将列宽更改为1000,但我想使用鼠标悬停框来显示所有单元格数据


还有其他可行的方法吗?

鼠标悬停可以实现,但我认为这很复杂。这里我有另一个更简单的想法:双击列表框,将显示一个包含所选列表项数据的多行文本框。此文本框的位置和大小与列表框相同。在用户窗体上,单击“隐藏文本框”。下面是一些示例代码,要测试它,您需要一个名为“ListBox1”的列表框表单:


您是想在工作表中还是在表格中显示数据?我不明白你在问什么。如果你的表格/列表框不重要,你只是想通过某种方式看到表格中的所有行,那么就这么说。我的工作表视图不重要,我的表格很重要。我希望它在我的表单的列表框中显示干净。最好有一个鼠标和一个小工具箱。但是我找不到任何人做过或尝试过这个。有多行的单元格,单元格中的每行是否代表列表中的一项?还是将整个单元格值放入单个列表项中。你能提供一些截图吗?(用链接更新您的问题)不客气。如果你喜欢这个答案,请投它一票。我很乐意得到一些分数:-)。
Option Explicit

Public ListItemInfo As Control

Private Sub UserForm_Initialize()
    Set ListItemInfo = Me.Controls.Add("Forms.TextBox.1", "ListItemInfo", False)
    With Me.ListItemInfo
        .Top = Me.ListBox1.Top
        .Left = Me.ListBox1.Left
        .Width = Me.ListBox1.Width
        .Height = Me.ListBox1.Height
        .MultiLine = True
    End With
End Sub

Private Sub ListBox1_Change()
    Me.ListItemInfo.text = GetSelectedItemsText
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    SwitchListItemInfo
End Sub

Private Sub UserForm_Click()
    SwitchListItemInfo
End Sub

Private Function GetSelectedItemsText() As String
    Dim text As String
    Dim i As Integer
    For i = 0 To Me.ListBox1.ListCount - 1
        If Me.ListBox1.Selected(i) Then
            text = text & Me.ListBox1.List(i) & vbNewLine
        End If
    Next i
    GetSelectedItemsText = text
End Function

Private Sub SwitchListItemInfo()
    If Me.ListItemInfo.text = "" Then Exit Sub
    Me.ListItemInfo.Visible = Not Me.ListItemInfo.Visible
    Me.ListBox1.Visible = Not Me.ListBox1.Visible
End Sub