Sub Sample()

    [A1:A20] = [INDEX(UPPER(A1:A20),)]

End Sub

Hi, For the above code that was provided by Siddharth Rout, is it possible to change the 20 to a variable such as last row in a worksheet?

Many thanks in advance.

有帮助吗?

解决方案

Try this:

Sub UpperCase()

    Dim TargetRng As Range, LastRow As Long
    LastRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
    Set TargetRng = Sheet1.Range("A1:A" & LastRow)

    TargetRng = Evaluate("INDEX(UPPER(" & TargetRng.Address & "),)")

End Sub

[] is just shorthand for Evaluate. Using the whole word has no penalties and can be used with VBA as well. Just tried it and it works.

Let us know if this helps.

其他提示

The only way would be to put the largest amount of rows possible. For Excel 2007 would be 1048576

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top