2013-04-29 44 views
0

目标:
我们的目标是从图片获得下面的结果Excel的VBA代码为大写所有细胞

enter image description here

问题:
目前的情况是低于

应该如何我这样做是为了通过使用VBA代码获得目标结果。

enter image description here

+0

你只是想以'大写'的文字? – 2013-04-29 22:57:01

回答

2

试试这个代码

Sub sample() 
Range("B4:E7") = [index(upper(B4:E7),)] 
End Sub 

enter image description here

+0

你愿意解释你的语法吗?为什么使用'index'?为什么',)'? – Floris 2013-04-30 03:58:43

+2

@弗洛伊斯我希望图像清除大部分事情。 – Santosh 2013-04-30 05:20:20

2
Dim rng As Range 
Dim cell As Range 

Set rng = Range("C4:F7") 

For Each cell In rng 
    cell.Value = UCase(cell) 
Next cell 
0

以前的答案让你包括的范围。如果你正在谈论所有单元格,这将起作用。

sub EverythingToUpperCase() 
    For Each Cell in ActiveSheet.UsedRange.Cells 
     Cell.Value = UCase(Cell.value) 
    Next 
End Sub 
0

最短的版本我已经看到:

随着目标“(结束与底部)

Target = UCase(Target) 'Ucase or Lcase 

    'Target = StrConv(Target, vbProperCase) '<< PROPER 

和..祢1班轮:

Selection.Value = UCase(Selection.Value) 'YES << 1 LINER UCASE (tested, worked), add a range