Excel's VB programming

zhaozj2021-02-11  227

The first problem that Excel programming is a header. Sometimes the form of the head is more complex and needs lateral or longitudinal merge unit. Please rest assured that as long as there is no slash, Excel can pay. ---- For example, the four cells you have merged, you recorded the macro code: Range ("A2: A5"). SelectWith Selection.horizontalalignment = xlCenter.VerticalAlignment = XLbottom.wrapText = false.orientation = 0.addindent = false.shrinktofit = false.mergecells = false.megecells = false.megecells = false --- and its own programming as long as a Range. ("A2: A5"). Mergecells = true can solve the problem. ---- The form is set, and then the content of the head is. If the length of the text in the cell exceeds the column width, it is often only possible to display some content. The content of the tail will "Eriority" into the right blank cell, very unrestitable. This problem can be resolved by setting column width in the program. ---- Column (14) .Columnwidth = 12 'Settings Group 14 List of 12 (the default column width is 8.38) ---- If you don't want to work, you will be estimated to estimate the colored wide, simply Come to a line ---- columns ("A: I"). Autofit 'A to i column Automatic adjustment column width ---- Let Excel strain strain. ---- But maybe you don't like this method, think that the head is widened, and it is too convenient to browse a small form. If you can keep the default column width, you will be able to automatically pick it up. No problem, Excel package you are satisfied. ---- Rows (3) .wraptext = true 'Let the text in the third line of the text in each cell ---- But you'd better add a row (3) .verticalALIGNMENT = XLTOP let the header automatically This is comparable to habits. ---- You can also put the top color to the head, so that your readers don't look at the yawn. ---- Rows (2). Interior .COLORINDEX = 5 'Set the 2nd line color is blue --- Topping the table on the table color, which is more eye-catching. ---- Rows (1) .font.colorindex = 4 ---- The head is completed after completion, one is filling it too slowly, if your data is stored in a two-dimensional array, That problem is much simpler. DIM DATA (3, 4) ......... 'Data Processing Range ("A2: D4"). Value = Data ---- This can fill in all the data in a table at a time! However, reminds the Range object size to match the array, unable to display all the data, which will only fill the "N / A" in the blank unit indicate that there is no data. ---- If you need to display multiple data tables in the result, you want to join a loop variable in the RANGE object, which is also good.

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

New Post(0)