VBA cells in one sheet to another sheet specific cells

scubadivingfool

New Member
Joined
Jun 17, 2010
Messages
35
OK, not sure how to go about this.

I have data in sheet1, Image right below, that I need to copy over to sheet 2. For example I need A2 on shhet1 to be copied to A8 on sheet2, B2 on sheet1 to A7 on sheet2, and B3 on sheet1 to A6 on sheet2. The number of cells on sheet 1 will be different ranging from 1 to 50 different cells. I am figuring that VBA is the best way but not sure how to get around this. Any help is appreciated.

Sheet1
1639334025929.png


Sheet2
1639333863737.png
 

Attachments

  • 1639333518224.png
    1639333518224.png
    8.8 KB · Views: 5

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
This is basic VBA:

Your example would be coded like this:
VBA Code:
Sub CopyCells()
   Dim ws1, ws2 As Worksheet
   Set ws1 = ThisWorkbook.Sheets("Sheet1")
   Set ws2 = ThisWorkbook.Sheets("Sheet2")
   
   ws2.Range("A8").Value2 = ws1.Range("A2").Value2
   ws2.Range("A7").Value2 = ws1.Range("B2").Value2
   ws2.Range("A6").Value2 = ws1.Range("B3").Value2
End Sub

In order to give you a more accurate answer I would need some more information on your data.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,586
Messages
6,125,689
Members
449,250
Latest member
azur3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top