Страницы: 1
RSS
Смена вывода данных со столбца на строку, Изменить вертикальный вывод на горизонтальный
 
Здравствуйте, на этом форуме мне как-то помогли с макросом:
Код
Private Sub ComboBox1_Change()
    Лист1.Range("A3:A42").ClearContents
    With Лист5
        Set rc = .Cells.Find(ComboBox1)
        If Not rc Is Nothing Then c = rc.Column
        .Cells(3, c).Resize(.Cells(.Rows.Count, c).End(xlUp).Row).Copy Лист1.[a3]
    End With
End Sub


всё правильно работает, но мне теперь нужно что-бы комбобокс вставлял данные не в столбик (А3:А42) а в строку, в диапазон С1:АР1
менял я местами... менял... не получается...
 
Код
Private Sub ComboBox1_Change()
    Лист1.Range("A3:A42").ClearContents
    With Лист5
        Dim c As Long
        Set rc = .Cells.Find(ComboBox1)
        If Not rc Is Nothing Then c = rc.Column
        Dim arr As Variant
        With .Cells(3, c).Resize(.Cells(.Rows.Count, c).End(xlUp).Row)
            If .Cells.Count = 1 Then
                ReDim arr(1 To 1, 1 To 1)
                arr(1, 1) = .Value
            Else
                arr = .Cells
            End If
        End With
        Лист1.[a3].Resize(UBound(arr, 2), UBound(arr, 1)) = Application.Transpose(arr)
    End With
End Sub
 
Спасибо, почти правильно, но тут я уже смог доделать:

Код
Private Sub ComboBox1_Change()
    Лист1.Range("C1:AF1").ClearContents
    With Лист5
        Dim c As Long
        Set rc = .Cells.Find(ComboBox1)
        If Not rc Is Nothing Then c = rc.Column
        Dim arr As Variant
        With .Cells(3, c).Resize(.Cells(.Rows.Count, c).End(xlUp).Row)
            If .Cells.Count = 1 Then
                ReDim arr(1 To 1, 1 To 1)
                arr(1, 1) = .Value
            Else
                arr = .Cells
            End If
        End With
        Лист1.[C1].Resize(UBound(arr, 2), UBound(arr, 1)) = Application.Transpose(arr)
    End With
End Sub
Страницы: 1
Наверх