English 中文(简体)
如何每次自动调整列宽和行宽优?
原标题:How to automatically adjust column and row widths in excel every time?
  • 时间:2024-08-11 21:19:19
  •  标签:
  • excel
  • macros
Inquiry I am interested in finding out a keyboard shortcut (or VBA macro) that will enable excel workbooks that I work with, to automatically adjust column widths and row widths. Concerning automatically adjusting row widths, say I have a cell enabled as wrapped text. Furthermore, let s say a particular cell now requires adjustment of that column; this could imply that the row height may need to be adjusted to be shorter (or taller). LINK I actually first contacted Microsoft; the following link is when I asked a question to Microsoft in a discussion forum. Link: https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-automatically-adjust-column-widths-in-excel/f88abb8b-7e65-40e6-8a03-83decab25420?messageId=24299486-63c2-4fa7-b693-a6ecd94d576d Please refer to this link to see how far I was able to get. WHAT I HAVE DONE After a representative from Microsoft replied to my question, I was given a code. I was given a macro code, and I tried it, and this did indeed work. I saved a trial excel workbook as a macro-enabled workbook. However, one keyboard shortcut that doesn t operate when I apply the macro is control + Z (the undo function). I m assuming there is possibly other keyboard shortcuts that may not function with the macro enabled code I was given. After a back and forth with Microsoft representatives, I was told that it may be in my best interest to go to stack overflow. CONCLUSION I am curious about a code that will automatically (and permanently) adjust column AND row widths, and simultaneously, ensure all traditional keyboard shortcuts still function (such as control + Z). I am not sure if my inquiry pertains VBA or macro (I am not sure if there is a different, and what is the difference). I was able to find one discussion that enables a code for row widths; however, I m looking for a code to also complete this for column widths, and possibly have a larger code (since it may define my inquiry for automatically adjust column AND row widths).
问题回答
Your macro is Sub SizeAutofit() Cells.Rows.AutoFit Cells.Columns.AutoFit End Sub To get the quick access method, click on "Customize Quick Access Toolbar" and select "More Commands". Select "Macros" in "Choose commands from:", select "SizeAutofit" and click "Add". To have the feature available everywhere, save it in the personal macro book.




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签