VBA Copy a Range from One Worksheet to Next Available Row in Another Sheet

I am hoping you can help me with a basic VBA code. I would like to copy two ranges from one worksheet to another worksheet in the same workbook. I have created a code that accomplishes this but I cannot figure out how to get it not to override previous information that is already there as it should go to the empty row underneath the row that already has information from a previous copy and paste function. For example I want to copy range A62:I65 and H1 from sheets(“GIS”) to sheets(“GIS Comments”) A2 and A3. Then when there is new information in sheets (“GIS”) copy the same range A62:I65 and H1 from sheets(“GIS”) to sheets(“GIS Comments”) in the next available empty  rows and so on (therefore not overriding information that is already in sheets(“GIS Comments”.

Expert Asked on August 10, 2015 in VBA: Programming.
Add Comment
4 Answer(s)

Hi Kris,

The below macro will help you to copy the data and paste at next available Row in the other worksheet.

RE: Copying Range from one worksheet to another worksheet

Sub CopyTheDataInToNextAvailableRow()
'find LastRow in Target Sheet
Dim lastRow As Long
Dim strTargetSheet As String
strTargetSheet = "GIS Comments"
lastRow = Sheets(strTargetSheet).Cells.SpecialCells(xlLastCell).Row
lRow = Sheets(strTargetSheet).Cells.SpecialCells(xlLastCell).Row
Do While Application.CountA(Sheets(strTargetSheet).Rows(lRow)) = 0 And lRow <> 1
lRow = lRow - 1
Loop
lastRow = lRow + 1
Range("A62:I65").Copy Destination:=Sheets(strTargetSheet).Range("B" & lastRow)
'Copy A62:I65----------------------> target sheet------ at Past in Column B
MsgBox "Copied and pasted at B" & lastRow
End Sub

Objective:

VBA code to copy a range and paste at next available row in other sheet

This macro will copy the data from Range A62: I65 in ‘GIS’ sheet to next available row in ‘GIS Comments’

Macro will always check for the next available row and paste the data in the avilable row. This will not over ride the existing data.                                                    

How to Run the Macro?

Paste some data in GIS at ranges highlighted in Yellow Color. And press the button

How to View the Macro?

Press Alt+F11 to view the macro

Thanks-PNRao!

Keymaster Answered on August 10, 2015.
Add Comment

Thank you so much it works great. I really appreciate all your help.

Expert Answered on August 11, 2015.
Add Comment

You are most welcome Kris! Thanks-PNRao!

Keymaster Answered on August 11, 2015.
Add Comment

What changes would you make to the code if “GIS Comments” is located in another workbook? like C:\Desktop\GIS_Comments.xlsx…

Contributor Answered on January 13, 2017.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.