Een familie van Microsoft-spreadsheetsoftware met hulpmiddelen voor het analyseren, in kaart brengen en communiceren van gegevens.
Dit antwoord is automatisch vertaald. Als gevolg hiervan kunnen er grammaticale fouten of vreemde formuleringen zijn.
Hoi, Richard Hs
U kunt de volgende code proberen. Let op, zorg ervoor dat Blad1 en Blad2 bestaan.
Dim wsSource As Worksheet
Dim wsDestination As Worksheet
Dim lastRow As Long
Dim i As Long
Dim destRow As Long
' Define the source and destination worksheets
Set wsSource = ThisWorkbook.Sheets("Sheet1") ' Assuming the original sheet name is "Sheet1"
Set wsDestination = ThisWorkbook.Sheets("Sheet2") ' Assuming the destination sheet name is "Sheet2"
' Get the last row of the source worksheet
lastRow = wsSource.Cells(wsSource.Rows.Count, "G").End(xlUp).Row
' Initialize destination row
destRow = 1
' Loop through the rows of the source worksheet
For i = 11 To lastRow
' Check if the value in the "G" column is greater than 0
If wsSource.Cells(i, "G").Value > 0 Then
' Clear the destination row before copying
wsDestination.Rows(destRow).Clear
' Copy the row to the destination worksheet if it meets the condition
wsSource.Rows(i).Copy Destination:=wsDestination.Rows(destRow)
destRow = destRow + 1
End If
Next i
End Sub
Deze kant is getest zonder afwijkingen, maar ik weet niet zeker of deze aan uw eisen voldoet, dus als dat niet het geval is, raad ik u aan enkele voorbeelden van gegevenslocaties in Excel te illustreren en vervolgens screenshots en meer gedetailleerde beschrijvingen te maken, zodat we uw probleem gemakkelijker kunnen begrijpen.
We kijken uit naar uw antwoord.
Hartelijke groeten
Yujun.F-MSFT | Ondersteuningsspecialist voor de Microsoft-community