0
Follow
2
View

VBA Loop search specific values in a selected range

dnrddnr 注册会员
2023-01-25 00:46

This error is caused because you've selected the wrong return type for the inputbox.

From microsoft's documention on Application.Inputbox (https://learn.microsoft.com/en-us/office/vba/api/excel.application.inputbox):

Value Description
0 A formula
1 A number
2 Text (a string)
4 A logical value (True or False)
8 A cell reference, as a Range object
16 An error value, such as #N/A
64 An array of values

Therefore you just need to change your 0 to an 8:

Set r = Application.InputBox("Select range", "Selection Window", Type:=8)

EDIT: To resolve the error 91 in the loop:

For Each word In Dictionary
  Set target_cell = r.Find(word)
  If Not target_cell Is Nothing Then
    target_cell.Interior.ColorIndex = 4
  End If
Next

About the Author

Question Info

Publish Time
2023-01-25 00:46
Update Time
2023-01-25 00:46

Related Question

关于如下简易通讯录程序Search函数设计的思路

Sklearn - GridSearchCV与refit = True的最佳估计器

Elasticsearch错误:unavailable_shards_exception

在ElasticSearch中使用NEST保存字典类型属性时遇到麻烦

vba处理Excel数据问题

aws connect search_available_phone_numbers API for python不工作

Jpa Specification泛型类型类

Sharepoint Cognitive Search Skillset

Scout:import将数字追加到elasticsearch索引名

dirsearch扫描速度慢