Need Help with a VBA subroutine

Joined
Dec 9, 2015
Messages
21
Reaction score
0
I'm working on an Excel spreadsheet and I need some help with a some VBA code. Here's what I want to do.

On Sheet1 in my spreadsheet I have 12 rows of data running from column A through column N.
On Sheet2 in my spreadsheet I have a formatted report laid out in 19 rows of data running from column A though column I.

What I want to do is be able to copy 2 adjacent cells on one row in Sheet1 to 2 specific adjacent cells in sheet2 but I want to be able to highlight (select) the row of data in sheet1 that I want to copy.

I was able to get this to work with the first row of data (Row 4) in Sheet1 with the following VBA subroutine.

Sub copydata()
Sheets("sheet1").Select
Range("D4:E4").Copy
Sheets("Sheet2").Select
Range("B14:C14").Select
ActiveSheet.Paste
Columns("B:C").AutoFit
End Sub

What I have not been able to figure out yet is how to make the code work when I select a different row of data. Can anyone explain to me how to do this so the date that's copied varies from row to row based on the row highlighted?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top