Copying and pasting the same cells but applying it to multiple sheets using VBA

whykillzee

New Member
Joined
Jun 28, 2017
Messages
19
Hi guys, I'm relatively new to VBA.

I am trying to copy and paste a fixed set of cells for multiple worksheets in the same workbook.

So i created a button at one of the worksheet.

Giving a brief example:

I have 4 worksheets named "Jan", "Feb", "Mar", "Apr".

All will have different data in the same cell position as shown below.

ABCDEFGHIJK
1
2234222111A
3345333123B
4456444666C
5567555888D
6678666222E
7789777333F

<tbody>
</tbody>


I have created a button at worksheet "Jan" to set a condition.

So if Cell B1 = 1, it is suppose to copy only column A2:A4 & A7 into Column B2:4 &B7 and Column D2:D4 & D7 into Column E2:E4 & E7. and it should only be applied to Jan and Feb worksheet.

if Cell B1 = 2, it is suppose to copy only column D2:D4 & D7 into Column E2:E4 & E7 and Column G2:G4 & G7 into Column H2:H4 & H7. and it should only be applied to Feb and Mar worksheet.

if Cell B1 = 3, it is suppose to copy only column G2:G4 & G7 into Column H2:H4 & H7 and Column J2:J4 & J7 into Column K. and it should only be applied to Mar and Apr worksheet.

if Cell B1 = 4, it is suppose to copy only column J2:J4 & J7 into Column K2:K4 & K7 and Column A2:A4 & A7 into Column B. and it should only be applied to Apr and Jan worksheet.

This is just an example. Because in my actual workbook, i have about 30+worksheet and i need to manually copy and paste value for 15+ worksheets.

So how do i write this code? Because from what i found online, i only managed to find those can loop through the whole workbook which i do not wish to do so.

Help!

Thanks in advance.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

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