5,140
社区成员
发帖
与我相关
我的任务
分享
Dim path As String
path = "d:\work"
FileName = Dir(path & "\*.xls")
FileName = path & "\" & FileName
Do While FileName <> "d:\work\"
......
FileName = Dir
FileName = path & "\" & FileName
Loop
Sub FindStrings()
Dim firstCell, nextCell, stringToFind As String
Dim nCursor As Integer
stringToFind = "@yahoo"
nCursor = 1
nextCell = ""
Sheet1.Select
Range("A1").Select
Range("A1").Activate
Set firstCell = Cells.Find(What:=stringToFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False)
If firstCell Is Nothing Then
MsgBox "Search Value Not Found.", vbExclamation
Else
Sheet2.Cells(1, nCursor).Value = firstCell
nCursor = nCursor + 1
Do While firstCell.Address <> nextCell
If nextCell = "" Then
nextCell = firstCell.Address
End If
nextCell = Cells.FindNext(After:=Range(nextCell)).Address
If firstCell.Address <> nextCell Then
Sheet2.Cells(1, nCursor).Value = Range(nextCell).Value
nCursor = nCursor + 1
End If
Loop
End If
End Sub