EXCEL programming solutions for adaptive heights of cross-column cells

xiaoxiao2021-03-06  44

Today, a report with Excel is modified. There is a data grid to cross two columns. The general single data is automatically transferred to achieve adaptive height, but the cross-column is not good. Find Google's long-lasting, no suitable method After a headache, suddenly there was a sense of inspiration, so I was tried immediately. I was really realistic. Let's write it first. If you are trapped in this question, you can have a little way. Principle: In another Sheet Using the characteristics of cells and adaptive heights, set a test cell width to the width of the actual spanning cell, and then put the characters you need to enter into the test cell, and obtain the high return to the actual cross-column unit. Yes. The following is a VB code private submmand1_click () Dim Objexcel As new Excel.Application Dim WKSheet as Excel.Worksheet Objexcel.Workbooks.open "E: /book1.xls"

Set wkSheet = Worksheets ( "Sheet1") wkSheet.Select Dim iWidth As Double iWidth = wkSheet.Columns. ( "A: A") ColumnWidth wkSheet.Columns. ( "B: B") ColumnWidth Set wkSheet = Worksheets ( "Sheet2 ") wkSheet.Select wkSheet.Columns (" A:. A ".) ColumnWidth = iWidth Range (" A1 ") Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlCenter .WrapText = True .Orientation = 0 .AddIndent = False. IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With ActiveCell.Value = "dsfsdafsdafasfsdafsadfdsafsdafa" Dim iHeight As Double iHeight = ActiveCell.RowHeight

转载请注明原文地址:https://www.9cbs.com/read-83151.html

New Post(0)