답변 해 주셔서 감사합니다. 나는 chuff가 쓴 코드를 사용했고 효과가 있었다. 그러나, 이것은 더 큰 코드의 일부일 뿐이며, 많은 주문 woorkbooks (1 - n)에서 7 장을 사용하여 동일한 작업을 수행해야합니다. 그래서, 나는 각 woorkbook에 대한 코드를 반복했지만 아무것도 변경하지 않습니다. 한 가지 중요한 점은 "True"는 Excel에서 OR 함수의 결과입니다.
Sub Teste2Sigma()
Windows("datacao_v2.xls").Activate
Sheets("SamList").Activate
Range("f2").Select
varPasta = ActiveCell
varDatacao = varPasta & "datacao_v2"
Sheets("SamList").Select
Columns(1).Find(What:="fim").Activate
fim = ActiveCell.Row 'linha correspondente ao "fim"
first = Cells(4, 3)
aux = Range(Cells(fim - 3, 1), Cells(fim - 3 - 9, 1)).Find(What:="GJ", SearchDirection:=xlPrevious).Row
last = Cells(aux + 1, 3)
nInt = (fim - (fim - aux) - 3)/(first + 2)
nVal = first * nInt + last 'número total de amostras lidas
nPlan = Ceiling(nVal/4)
media = Range(Cells(2, 1), Cells(nPlan + 1, 1))
For K = 1 To nPlan
Windows(K & ".xls").Activate
Dim c As Range
Dim ClearAddress As String
Dim ClearRow As Long
With Worksheets("Standard 1").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Standard 2").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Sample 1").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Sample 2").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Sample 3").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Sample 4").Range("AI3:AJ42")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Blank").Range("Z7:Z46")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 1).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
With Worksheets("Blank").Range("AA7:AA46")
Set c = .Find(What:="True", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
ClearAddress = c.Address
Do
ClearRow = c.Row
Cells(ClearRow, 23).Value = ""
Set c = .FindNext(c)
Loop While c.Address <> ClearAddress
End If
End With
Next K
End Sub
은 BTW 루프 라인은'C 여기에 아무것도 없을 수 없기 때문에 루프 c.Address <> ClearAddress'은 (이미 테스트 동안 일한다고) 그리고 그 라인의 경우 Address 속성을 테스트하려고 시도하여 오류가 발생했습니다. – JosieP
Thanks @ JosieP. 코드를 수정했습니다. – chuff