gpt4 book ai didi

excel - 如何在for循环中提供一个变量来循环一个范围

转载 作者:行者123 更新时间:2023-12-04 22:08:08 27 4
gpt4 key购买 nike

Dim FromRang As Range, ToRang As Range
Dim UserCell As Range
'Ask the user to input the cell Range in which to search for the sub strings
Set FromRang = Application.InputBox(Prompt:="Enter Search Range From:", Type:=8)
Set ToRang = Application.InputBox(Prompt:="Enter Search Range To:", Type:=8)

For each UserCell in ("FromRang:ToRang")

给出类型不匹配错误

请帮忙..

最佳答案

看过您之前的问题后,您不需要两个单独的变量来捕获范围。
Set fullRange = Application.InputBox(Prompt:="Enter Search Range:", Type:=8)即您可以在输入框处于事件状态时选择范围。此外,您可以输入 A1:A10
然后,你可以做

For each UserCell in fullRange
...
Next

关于excel - 如何在for循环中提供一个变量来循环一个范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16321325/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com