|
下記の通りコード書いたのですが、ラベルの表示(Caption)がうまくいきません。ご指導のほどよろしくお願いいたします。
Sub ken_Click()
Dim adrs As Variant
Dim addr As Variant
Dim theadd As Variant
Dim i As Integer
i = 0
Worksheets("結果").Select
Range("A3:A60000").Select
Selection.ClearContents
theadd = adr.Value
'下記の"検索中…"が実行時に表示されない。
kensu.Caption = "検索中…"
With Worksheets(1).Range("a1:c35000")
Set adrs = .Find(theadd)
If Not adrs Is Nothing Then
addr = adrs.address
Do
i = i + 1
Worksheets(1).Select
adrs.Select
Selection.Copy
Worksheets("結果").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets(1).Select
Set adrs = .FindNext(adrs)
Loop While adrs.Value = adrs And adrs.address <> addr
Worksheets("結果").Cells(2, 1).Value = i - 1
Worksheets(2).Select
Range("A3:A65000").Select
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin
Worksheets(2).Select
ListBox1.RowSource = Worksheets(2).Range(Worksheets(2).Cells(3, 1), Worksheets(2).Cells(d, 1)).address
kensu.Caption = "該当件数" & (Worksheets(2).Cells(2, 1).Value) & "件"
Else
MsgBox "該当なし"
End If
End With
Application.CutCopyMode = False
Worksheets(1).Select
Range("A1").Select
End Sub
よろしくお願い致します。
|
|