|
借用老师的下面代码,想请老师再给修改一下,清空A5单元格中的连续的三个汉字。请给予修改,谢谢
Private Sub CommandButton1_Click()
Dim mypath As String
Dim sht As Worksheet
Dim MyFile As String
Application.ScreenUpdating = False
mypath = ThisWorkbook.Path & "\"
myname = Dir(mypath & "*.xls")
Do While myname <> ThisWorkbook.Name And myname <> ""
Workbooks.Open mypath & myname
With ActiveWorkbook
s$ = Left(myname, 1)
If InStr("ABCD", s) Then
For Each sht In Sheets
If Left(sht.Name, 3) = s & "01" Then sht.Range("A5") = Replace(sht.Range("A5"), " ", "")
Next
End If
ActiveWorkbook.Close True
End With
myname = Dir
Loop
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton1_Click()
Dim mypath As String
Dim sht As Worksheet
Dim MyFile As String
Application.ScreenUpdating = False
mypath = ThisWorkbook.Path & "\"
myname = Dir(mypath & "*.xls")
Do While myname <> ThisWorkbook.Name And myname <> ""
Workbooks.Open mypath & myname
With ActiveWorkbook
S$ = Left(myname, 1)
If InStr("ABCD", S) Then
For Each sht In Sheets
If Left(sht.Name, 3) = S & "01" Then
CL = sht.Range("A5").Value
S = InStr(CL, "省")
T = InStr(CL, "市")
sht.Range("A5") = Left(CL, S) & Right(CL, Len(CL) - T)
End If
Next
End If
ActiveWorkbook.Close True
End With
myname = Dir
Loop
Application.ScreenUpdating = True
End Sub
|
|