Hello,
I am trying to create a macro in Excel in which for a given range of data, say A32:L100, if a cell in column C has a certain value, the macro will copy and paste data from that row onto another sheet in the next empty row. Below is an example of the code I have, which gives the right general idea, but instead of pasting to a particular cell, I want it to go to the next available row (and of course, it would be nicer if I didn't have to specify row by row which cell to evaluate).
Sheets("JOURNAL ENTRIES").Select
Range("C32").Select
If (Range("C32") = "PBD SURG FOREIGN PAT") Then
Range("A32:L32").Copy
Sheets("PRINT SHEETS").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Sheets("JOURNAL ENTRIES").Select
Range("C33").Select
If (Range("C33") = "PBD SURG FOREIGN PAT") Then
Range("A33:L33").Copy
Sheets("PRINT SHEETS").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Sheets("JOURNAL ENTRIES").Select
Range("C34").Select
If (Range("C34") = "PBD SURG FOREIGN PAT") Then
Range("A34:L34").Copy
Sheets("PRINT SHEETS").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
EndSub
I hope this makes sense and I appreciate any help.
Evelyn
I am trying to create a macro in Excel in which for a given range of data, say A32:L100, if a cell in column C has a certain value, the macro will copy and paste data from that row onto another sheet in the next empty row. Below is an example of the code I have, which gives the right general idea, but instead of pasting to a particular cell, I want it to go to the next available row (and of course, it would be nicer if I didn't have to specify row by row which cell to evaluate).
Sheets("JOURNAL ENTRIES").Select
Range("C32").Select
If (Range("C32") = "PBD SURG FOREIGN PAT") Then
Range("A32:L32").Copy
Sheets("PRINT SHEETS").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Sheets("JOURNAL ENTRIES").Select
Range("C33").Select
If (Range("C33") = "PBD SURG FOREIGN PAT") Then
Range("A33:L33").Copy
Sheets("PRINT SHEETS").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Sheets("JOURNAL ENTRIES").Select
Range("C34").Select
If (Range("C34") = "PBD SURG FOREIGN PAT") Then
Range("A34:L34").Copy
Sheets("PRINT SHEETS").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
EndSub
I hope this makes sense and I appreciate any help.
Evelyn