VBA Как автоматически подобрать высоту строки с помощью объединенных ячеек? - PullRequest
0 голосов
/ 27 октября 2018

У меня есть динамические данные, не установленные в высоте данных.Как установить динамическую высоту в высоте данных.

sub test()
    Sheets(1).Cells(2, 16).Value = "Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal."
End sub

Отображение полных данных в ячейке теперь, как я могу использовать "WrapText" и "AutoFit", но ячейка для отображения полных данных, но больше, чем слово, скрытое в ячейке.высота строки 409. Как увеличить высоту ячейки

1 Ответ

0 голосов
/ 27 октября 2018

Не используйте ячейку слияния и автоподгонку, используйте только текст переноса и установите для ширины столбца любое желаемое число, которое будет хорошо смотреться на ваших данных.

Sub test()

    Dim row_num
    Dim col_num

    row_num = 2
    col_num = 16

    Columns(col_num).ColumnWidth = 65

    Sheets(1).Cells(row_num, col_num).Value = "Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working  normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal.Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same.To convert graphic display.After transfer to HMI and test operation finished." _
    & "Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal."

    Sheets(1).Cells(row_num, col_num).WrapText = True

End Sub

Отредактированная версия

Вы можете проверить приведенный ниже код для автоматической подгонки объединенных ячеек.

Ширина ячейки для столбцов от А до С установлена ​​равной 12, а для высоты соотношение, составляющее 45% длины текста, зависит от этой ширины. Если вы хотите изменить ширину, вам также нужно изменить соотношение .

Sub test1()


    Sheets(1).Cells(2, 1).Value = " Testing Testing TestingTestingTesting Testing Testing TestingTestingTesting Testing TestingTesting Testing Testing TestingTesting Testing Testing Testing TestingTesting Testing TestingTesting Testing Testing Testing Testing Testing Testing Testing TestingTestingTesting Testing"
    Range("A2:C2").Merge
    Range("A2:C2").WrapText = True

    Columns("A:C").ColumnWidth = 12

    text_length = Len(Sheets(1).Cells(2, 1).Value)
    Rows("2:2").RowHeight = text_length * 0.45


End Sub
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...