PDA

View Full Version : Pasting to the next row in a list



aecky01
03-01-2008, 11:41 AM
Hi everyone,

I'm trying my best to learn VBA but I'm stuck with a problem that shouldn't take too long to figure out. Basically I want to past a range of cells from the newest worksheet into a summary list. This data needs to be pasted to the bottom of the list. I was trying to count the number of rows, and then add that value to the starting row to get the next row that doesn't have a value in it. Heres my code for the part that I'm stuck on, I know the snytax is not right, but hopefully it will give you an idea what I'm trying to accomplish.

Sub Update()
Sheets(2).Select
ActiveSheet.Unprotect
Range("P27:W27").Select
Selection.Copy
Sheets(1).Select
h = Range("B113").Value
Range("B" & "72+h").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks :=False, Transpose:=False
End Sub

Thanks for any help you can give. I'm not sure if this is even the right way to got about this situation, so I'm open to any suggestions. Thanks

Bob Phillips
03-01-2008, 11:46 AM
Sub Update()
With Sheets(2)
.Unprotect
.Range("P27:W27").Copy
Sheets(1).Range("B1").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
.Protect
End With
End Sub

aecky01
03-01-2008, 12:04 PM
Is there any way to use the code to paste to the bottom of the list. When I added to code to my macro it copies to the top of the list.

Bob Phillips
03-01-2008, 12:24 PM
Do you have some gaps in the list?

aecky01
03-01-2008, 12:32 PM
Sorry I just had to adjust the cell range, it works perfectly thanks