Copy and Paste Specific Cells from one worksheet to another

前端 未结 2 1777
南笙
南笙 2021-01-28 23:05

I have a spreadsheet Sheet1 I have a row with some cell values as shown in Image 1. I am having a problem trying to copy and paste cells from one worksheet to another in excel.

相关标签:
2条回答
  • 2021-01-28 23:43

    For the first cell on Sheet2, write:

    =Sheet1!A4
    

    Then the other two as follows:

    =Sheet1!D4
    =Sheet1!G4
    

    That is, if you want to have the same values even if you update the ones on Sheet1. If not, perhaps you want vba code? Create a new module:

    sub copy()
    
    dim sheet1 as Worksheet, sheet2 as Worksheet
    
    sheet1 = Worksheets("Sheet1")
    sheet2 = Worksheets("Sheet2")
    sheet2.Cells(1,"A").Value=sheet1.Cells(4,"A").Value
    sheet2.Cells(2,"A").Value=sheet1.Cells(4,"D").Value
    sheet2.Cells(3,"A").Value=sheet1.Cells(4,"G").Value
    
    end sub
    
    0 讨论(0)
  • 2021-01-28 23:48

    Try this script.

    Sub CopyData1()
    Dim cell As Range, rw As Long
    rw = 2
    For Each cell In ActiveSheet.Range("A1:H20")
    If Not IsEmpty(cell) = True Then
    Worksheets("Sheet2").Cells(rw, 1).Value = cell.Value
    rw = rw + 1
    End If
    Next
    End Sub
    

    I'm assuming you have a sheet named 'Sheet2'. If not, just rename the sheet where you want the values copied to.

    0 讨论(0)
提交回复
热议问题