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.
<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.
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.
A | B | C | D | E | F | G | H | I | J | K | |
1 | |||||||||||
2 | 234 | 222 | 111 | A | |||||||
3 | 345 | 333 | 123 | B | |||||||
4 | 456 | 444 | 666 | C | |||||||
5 | 567 | 555 | 888 | D | |||||||
6 | 678 | 666 | 222 | E | |||||||
7 | 789 | 777 | 333 | F |
<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.