将整个范围转换为小写,而无需遍历单元格间接 [英] Convert entire range to lowercase without looping through cells Indirect
问题描述
我正在查看VBA代码,该代码将整个单元格范围转换为小写形式.我发现了以下内容:
I'm looking at VBA code that takes an entire range of cells and converts them into lowercase. I found the following:
[A1:A20] = [index(lower(A1:A20),)]
这在固定范围内可以很好地工作(不完全了解语法,但是找到了以下帖子:)
This works fine for a fixed range (don't entirely understand syntax, but found the following post:)
我的问题是这样
我希望能够动态设置范围,因为我正在处理不断变化的范围大小.但是,以下操作不起作用,而且我似乎也无法在VBA中使用INDIRECT().
I would like to be able to set the range dynamically as I'm dealing with changing range sizes. However, the following doesn't work, and I can't seem to be able to use INDIRECT() either in VBA.
Range("A1:A" & n) = [index(lower(Range("A1:A" & n)),)]
有没有办法使这项工作有效?我真的想避免使用for循环,因为我怀疑这应该快得多.
Is there a way to make this work? I would really like to avoid using a for loop as I suspect this should be a lot faster..
推荐答案
尝试一下:
Range("A1:A" & n) = Application.Evaluate("index(lower(A1:A" & n & "),)")
这篇关于将整个范围转换为小写,而无需遍历单元格间接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!