PDA

View Full Version : Solved: extract data in row 1 of sheet 1 into sheet 2



rafi_07max
11-18-2010, 12:28 AM
When I click button it should copy the entire row 1 from sheet 1 and paste into sheet 2 of row 1, if row I of sheet 2 is already has data in it ,then copy the data from the sheet 1 row 1 into sheet 2 of row2,
Likewise if the row 2 of sheet 2 has data in it I want it to copy the data in row 1 of sheet 1 into row 3 of sheet 3.
I want this process to repeat.

i have attached a sample worksheet
4927

Bob Phillips
11-18-2010, 01:17 AM
Private Sub CommandButton1_Click()
Dim Lastrow As Long

With Worksheets("Sheet2")

If .Range("A1").Value = "" Then

Lastrow = 1
Else

Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End If
Rows(1).Copy .Cells(Lastrow, "A")
End With
End Sub

rafi_07max
11-18-2010, 01:28 AM
Thanks xld that worked

rafi_07max
11-18-2010, 04:10 AM
one question xld, right now your codes coping everything inside the cell including the formula in it.
But Is it possible for the macro to just copy the cell value without copying the formula in it?

Bob Phillips
11-18-2010, 06:27 AM
Private Sub CommandButton1_Click()
Dim Lastrow As Long

With Worksheets("Sheet2")

If .Range("A1").Value = "" Then

Lastrow = 1
Else

Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End If
Rows(1).Copy .Cells(Lastrow, "A")
.Rows(Lastrow).Value = .Rows(Lastrow).Value
End With
End Sub

rafi_07max
11-18-2010, 07:06 AM
Thanks xld for your time and help