Dazzler
Dazzler

Reputation: 382

Copy and Paste Specific Cells from one worksheet to another

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. As shown in the below Image 1, I have a row with values and I want to copy the cells from Sheet1 and paste it to Sheet2 as shown in Image 2.

Image 1

Image 2

Can anyone please tell me how to do that?

Upvotes: 0

Views: 1235

Answers (2)

ASH
ASH

Reputation: 20302

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.

Upvotes: 0

mhyst
mhyst

Reputation: 297

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

Upvotes: 3

Related Questions