如何获取将数据从sheet2复制到sheet1的代码

时间:2019-06-21 12:30:38

标签: excel vba

获得代码以显示变量的值,而不是复制到Sheet1。我该如何将代码复制到新工作表中

获得用于显示值地址的代码,需要将其复制到Sheet1

Sub check_0_2()

    Dim wb     As Workbook
    Set wb = ThisWorkbook
    Dim ws     As Worksheet
    Set ws = wb.Sheets("Sheet2")
    Dim ws2 As Worksheet
    Set ws2 = wb.Sheets("Sheet1")
    Dim rng    As Range
    Set rng = ws.Range("A1").CurrentRegion
    Dim cell   As Range
    Dim lastrow As Long
    For Each cell In rng
        If cell.Value = 0 Then
        lastrow = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
            ws2.Range("A" & lastrow).Value = cell.Value
            Debug.Print "found in " & cell.Address
        End If
        lastrow = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
    Next cell
End Sub

在A1单元格中仅显示0,应该更多

0 个答案:

没有答案