|
>SubまたはFunctionが定義されていません。
>と出てしまいます・・・
当然です。
VBEtior画面で、標準モジュールを追加。
下記をコピペ。
Sub kensaku()
On Error Resume Next
Dim Area As Range
Dim Target As Range
Dim namae As String
Cells(ActiveCell.Row, "d").Activate
With UserForm1.TextBox1
namae = .Text
If namae = vbNullString Then
MsgBox "何か入力してね。"
.SetFocus
Exit Sub
End If
Set Area = ActiveSheet. _
Range("D2:D" & Range("D" & Rows.Count). _
End(xlUp).Row)
Set Target = Area.Find _
(What:=namae, _
After:=ActiveCell, _
LookIn:=xlValues, _
MatchCase:=True)
If Target Is Nothing Then
MsgBox "該当者はいません。", _
vbInformation, "Nothihg"
.SetFocus
Set Area = Nothing
Set Target = Nothing
Exit Sub
End If
Set Target = Area.FindNext(ActiveCell)
Target.Activate
End With
Set Area = Nothing
Set Target = Nothing
End Sub
Sub hyouji()
UserForm1.Show vbModeless
Range("D2").Activate
End Sub
続きあり。
|
|