返回列表 上一主題 發帖

顯示第一個字請問要如何修改內容

資料搜尋指定由P4到AF25儲存格問題

資料搜尋.rar (14.17 KB)
Private Sub ComboBox1_Change()
Dim A As Range
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
.Cells.Interior.ColorIndex = xlNone
For Each A In .UsedRange
  If A = ComboBox1.Text Then d(A.Address(0, 0, xlA1)) = "": A.Interior.ColorIndex = 6
Next
End With
Unload Me

End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Click()
End Sub

Private Sub UserForm_Initialize()
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
For Each A In .UsedRange
   If A <> "" Then d(A.Value) = ""
Next
Label1.Caption = .Name
.Cells.Interior.ColorIndex = xlNone
End With
ComboBox1.List = d.keys
End Sub

指定只從P4搜尋到AF25儲存格為止請各位指教謝謝

TOP

回復 1# gca78000


    謝謝大大指導小弟煩請在指導一下
如只要尋P4:P25及R4到R25及T4到T25及V4到V25
要如何改請指導謝謝

TOP

本帖最後由 gca78000 於 2015-11-19 13:42 編輯

回復 3# gca78000 姓氏搜尋.rar (15.52 KB)
請問如下Private Sub ComboBox1_Change()
Dim A As Range
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
.Cells.Interior.ColorIndex = xlNone
For Each A In .Range("P4:P25,R4:R25,T4:T25,V4:V25")

  If A = ComboBox1.Text Then d(A.Address(0, 0, xlA1)) = "": A.Interior.ColorIndex = 6
Next
End With
Unload Me

End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Click()
End Sub

Private Sub UserForm_Initialize()
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
For Each A In .Range("P4:P25,R4:R25,T4:T25,V4:V25")

   If A <> "" Then d(A.Value) = ""
Next
Label1.Caption = .Name
.Cells.Interior.ColorIndex = xlNone
End With
ComboBox1.List = d.keys
End Sub
P4:P25可搜尋到而R4:R25後卻蒐尋不到請指導謝謝

TOP

回復 4# gca78000 請問各位
如只要搜尋單姓氏要如何修改請指導謝謝

姓氏搜尋.rar (15.52 KB)

TOP

顯示第一個字請問要如何修改內容

姓氏搜尋.rar (15.81 KB)
請問各位高手如下列程式碼如果只要顯示第一個字請問要如何修改內容
Private Sub ComboBox1_Change()
Dim A As Range
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
.Cells.Interior.ColorIndex = xlNone
For Each A In .Range("P4:P25,R4:R25,T4:T25,V4:V25")

  If A = ComboBox1.Text Then d(A.Address(0, 0, xlA1)) = "": A.Interior.ColorIndex = 6
Next
End With
Unload Me

End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Click()
End Sub

Private Sub UserForm_Initialize()
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
For Each A In .Range("P4:P25,R4:R25,T4:T25,V4:V25")

   If A <> "" Then d(A.Value) = ""
Next
Label1.Caption = .Name
.Cells.Interior.ColorIndex = xlNone
End With
ComboBox1.List = d.keys
End Sub

姓氏搜尋.rar (15.81 KB)

回復 7# GBKEE
感謝版主用心解答小弟受教了謝謝版大感恩你

TOP

        靜思自在 : 心中常存善解、包容、感思、知足、惜福。
返回列表 上一主題