amandabstewart
New Member
- Joined
- Aug 4, 2014
- Messages
- 45
this works, BUT, when I run the macro again, it copies old data as new at the bottom. it's ok for it to overwright content in A2 on the destination page, but it takes the data like it is new and I get repeat data in the destination table.
any ideas? trying to delete either of the set pastecell parts causes the macro to die
Option Explicit
Sub CopyP2()
Dim PatientCol As Range
Dim Patient As Range
Dim PasteCell As Range
Set PatientCol = Sheet1.Range("A2:A99")
For Each Patient In PatientCol
If Sheet4.Range("A2") = "" Then
Set PasteCell = Sheet4.Range("A2")
Else
Set PasteCell = Sheet4.Range("A1").End(xlDown).Offset(1, 0)
End If
If Patient = "P2" Then Patient.EntireRow.Copy PasteCell
Next Patient
End Sub
any ideas? trying to delete either of the set pastecell parts causes the macro to die
Option Explicit
Sub CopyP2()
Dim PatientCol As Range
Dim Patient As Range
Dim PasteCell As Range
Set PatientCol = Sheet1.Range("A2:A99")
For Each Patient In PatientCol
If Sheet4.Range("A2") = "" Then
Set PasteCell = Sheet4.Range("A2")
Else
Set PasteCell = Sheet4.Range("A1").End(xlDown).Offset(1, 0)
End If
If Patient = "P2" Then Patient.EntireRow.Copy PasteCell
Next Patient
End Sub