|
kawataです。
ひでさん、どうもです。
>d_cnt() の数値を決めてるコードを教えてください
Private Function d_cnt() As String
Dim FoundCell As Range, SearchArea As Range
Dim read_file As String, k_word As String
Application.ScreenUpdating = False
read_file = "C:\aaa\bbb\ccc.txt"
k_word = "キーワード"
Workbooks.OpenText Filename:=read_file, StartRow:=1, _
DataType:=xlFixedWidth,FieldInfo:=Array(0, 2)
target_book = ActiveWorkbook.Name
target_sheet = ActiveSheet.Name
With Workbooks(target_book)
With .Sheets(target_sheet)
Set SearchArea = .Range("a:a")
Set FoundCell = SearchArea.Find(what:=k_word, lookat:=xlPart)
If Not FoundCell Is Nothing Then
d_cnt = FoundCell.Row - 5
End If
Set FoundCell = Nothing
End With
.Close False
End With
Application.ScreenUpdating = True
End Function
というコードで処理してます。
一応、Msgboxでは、望む数値が出ているのですが・・・・・・・・・。
よろしくお願いします。
|
|