简体   繁体   English

如何在整个列中用括号括住Excel单元格内容?

[英]How do I enclose an Excel cell contents with parentheses for an entire column?

I have an Excel document with data needs to be enclosed with parentheses. 我有一个Excel文档,其中的数据需要用括号括起来。

data for 1 cell would look like: 1个单元格的数据如下所示:

1234,'2000-01-01',3750000.000000,3750000.000000,3750000.000000,3750000.000000,0 1234,'2000-01-01',3750000.000000,3750000.000000,3750000.000000,3750000.000000,0

I want it to look like: 我希望它看起来像:

(1234,'2000-01-01',3750000.000000,3750000.000000,3750000.000000,3750000.000000,0) (1234,'2000-01-01',3750000.000000,3750000.000000,3750000.000000,3750000.000000,0)

This would need to be for an entire column though. 不过,这将需要用于整个列。 Sounds like a macro might be the best way to do this though I am not sure. 尽管我不确定,听起来宏可能是执行此操作的最佳方法。

A simple example for column B : B列的一个简单示例:

Sub parens()
   Dim r As Range

   For Each r In Intersect(Range("B:B"), ActiveSheet.UsedRange)
      If r.Text <> "" Then
         r.Value = "(" & r.Text & ")"
      End If
   Next r
End Sub

If you are only looking to do this for a single column, and don't mind adding a new column to the sheet, the "concatenate" function can do this job rather well too. 如果您只想对单个列执行此操作,并且不介意在工作表中添加新列,则“连接”功能也可以很好地完成此工作。

Example: 例:

=Concatenate("(",A2,")")

Then all you need to do is click the bottom right corner of the cell and drag to the bottom of the column. 然后,您所需要做的就是单击单元格的右下角,并将其拖到列的底部。 Copying and pasting works well too of course. 复制和粘贴当然也很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用括号括起来的单元格内容,ms excel,format - enclose contents of cell in brackets, ms excel, format 如果特定列中的单元格有数据,如何告诉 Excel 宏删除整行? - How do I tell an excel macro to delete the entire row if cell in a specific column have data? Excel 宏/VBA - 如果一列中的单元格为空,如何删除整行? - Excel Macro / VBA - How do I delete an entire row if a cell in one column is blank? 如何在Excel中告诉单元格包含整个行的总和 - How do i tell a cell to contain the sum of a entire row in excel Excel如何在Excel中检查单元格,如果它为空然后将前一个单元格的内容移到当前单元格 - Excel how do i check a cell in excel, if it's empty then shift the contents of the previous cell to current cell 如何使Excel单元格内容不可见 - How do I make a Excel cell contents invisible 如何在 Excel 宏中使用选定单元格的内容? - How do I use the contents of a selected cell in an Excel Macro? 如何使Excel单元格内容显示不同的值 - How do I make Excel cell contents show a different value 如何检查单元格的内容是否为数组中的值-VBA Excel - How do I check if the contents of a cell is a value in an array - VBA Excel 如何将 Excel 单元格的内容设置为等于字符串变量? - How do I set the contents of an Excel cell equal to a string variable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM