[英]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.