코드가 잘 작동하는 곳에서 코드를 작성하면됩니다. 보고서를 원하지만 코드를 복사하는 동안 한 열만 제외하고 싶습니다. 한 파일에서 다른 파일로 데이터. 내 코드는 A 열에서 A 열로 복사하지만 H에서 모든 데이터를 제외하고 빈 열 H가 없도록 데이터를 I에서 H로 옮깁니다.이 도움말이 도움이 되었기를 바랍니다.열을 건너 뛰고 해당 열을 복사하지 않고 다른 열을 복사하는 방법
Sub Distinct()
Const TRNS_START As String = "TRNS"
Const TRNS_END As String = "ENDTRNS"
Const COMPANY As String = "Triumph Foods LLC"
Dim searchRng As Range, copyRngStart As Range, copyRngEnd As Range
Set searchRng = Worksheets("Information").Range("A1")
' Enter/continue loop while A-column is non-empty
Do While searchRng.Value <> ""
' When we encounter the string TRNS in column A and Triumph Foods LLC in column E
If searchRng.Value = TRNS_START And _
searchRng.Offset(0, 4).Value = COMPANY Then
Set copyRngStart = searchRng ' Set the start of the copy area
End If
' When we encounter the string ENDTRNS
' (*and had a start cell already*)
If searchRng.Value = TRNS_END And Not copyRngStart Is Nothing Then
Set copyRngEnd = searchRng.Offset(-1, 8)
copyRngEnd.Worksheet.Range(copyRngStart, copyRngEnd).Copy _
Destination:=Sheets("Display").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Set copyRngStart = Nothing 'clear the "start" range
End If
Set searchRng = searchRng.Offset(1, 0)
Loop
End Sub
감사합니다. – AndresBryan29