当其中一些数字为负数时,如何在 Microsoft Excel 中按小数点对齐一列数字?

Att*_*s29 11 microsoft-excel microsoft-excel-2011

假设我有以下数字的列表:

0.02
-0.25
-4.13
5.24
-11.36
40.61
-141.20
Run Code Online (Sandbox Code Playgroud)

我将如何在列中对齐它们,使它们在单元格中左对齐但小数点对齐?

例如,

|   0.02    |
|  -0.25    |
|  -4.13    |
|   5.24    |
| -11.36    |
|  40.61    |
|-141.20    |
Run Code Online (Sandbox Code Playgroud)

I was tempted to use the "Accounting" category, but this transformed my negative values by adding parentheses.

I'm using Excel for Mac 2011.

小智 15

After you left-justify the cell, try this number format:

_-???0.0??;-???0.0??;
Run Code Online (Sandbox Code Playgroud)

To apply it, right-click on the cell, select "Format Cells", go to "Number" tab, go to "Custom" format option, and paste the format string into the "Type:" field.

How it works:

  • left most _- inserts whitespace equal to width of a "-" character;
  • ? takes up space equal to that of a number if the number is not present;
  • semicolon divides the format for the positive number (first part) from the format for the negative number (second part).

More in Excel number formats: Number format codes.

请注意,此格式仅适用于小数点左侧最多 4 位的数字。如果你有更大的数字,你需要添加更多的问号。