一个关于用VBA在excel查找字符串的问题

2024-11-22 23:46:36
推荐回答(2个)
回答(1):

Dim 我就不写了,整个程序我也不写了,只写你需要的
Dim rag as object 其他的都是int

a = Sheets("期房").[b65536].End(xlUp).Row
j = Sheets("录入").[c65536].End(xlUp).Row
b = 5
For Each Rac In Sheets("录入").Range("C1:C" & j)
If Not (Rac.Text = "住宅" Or Rac.Text = "公寓" Or Rac.Text = "商业" Or Rac.Text = "工业" Or Rac.Text = "车库" Or Rac.Text = _
"综合" Or Rac.Text = "其它" Or Rac.Text = "办公" Or Rac.Text = "别墅") Then
MsgBox "录入用途(C列)请在“住宅,公寓,别墅,商业,工业,办公,车库,综合,其它”中选择"
Exit Sub
End If

Next

For Each Rag In Sheets("期房").Range("A5:j" & a)
If Rag.Text Like TextBox1.Text Then
r = Rag.Row
b = b + 1
End If
Next

这个是模糊查询

For Each Rag In Sheets("期房").Range("a5:j" & a)
If Rag.Text Like "*" & ComboBox1.Text & "*" Then
Cells(b, 4) = Rag.Text
Cells(b, 1) = Rag.Offset(, -3).Text
Cells(b, 2) = Rag.Offset(, -2).Text
Cells(b, 3) = Rag.Offset(, -1).Text
b = b + 1
End If
Next

回答(2):

自带的功能就能查找啊,你要的查找我没看来有什么特殊,还是需要处理查找结果