Excel VBA set multiple cells to the same value from one sheet to another

Raychin

New Member
Joined
Apr 7, 2022
Messages
25
Office Version
  1. 2013
Platform
  1. Windows
Hello!
I have the following task/problem. I have to set a master file with 3 sheets. The Sheet1 (Prediction) contains data as hours from a month so 720 to 744 hours. The task is :
1. To add to the Sheet2 (Energy 15-min Prediction) the value from every single cell from Sheet1 range from B6:B725 to Sheet2 cloned into every 4 cells. So basically to divide every single hour to 4 15min periods. Per example Sheet1 B6 have to go to Sheet2 B6:B9 cells wit the same value (S1 B6=10 ---> S2 B6:B9=10) and so on for the next 720 to 744 rows from S1 to be transferred to S2 B6:B2885.
2. The same main idea but this time the data in every Sheet4 (Power 15-min Prediction) group of 4 has to be divide to the corresponding cell from Sheet1; so er example S1 B6 ---> S4 B6:B9 every cell divided to the S1 B6 and so on S4 B10:B13 divided to S1 B7

I have started with some code, it is not complete at all, just an idea for me to solve the tasks. Otherwise i have to put it manually for both new sheets (Energy 15-min Prediction and Power 15-min Prediction)...
Here's my idea :

Sub Set_Cells()

Dim i As Long

With ActiveWorkbook

For i = 6 To 724 Step 4

.Sheets("Prediction").Cells(i, 4) = .Sheets("Energy 15-min Prediction").Cells(b6, b2880).Value

.Sheet"Prediction".Cells(i, 4) = "Energy 15-min Prediction".Cells(13, 31).Value

Next i

End With

End Sub
 

Attachments

  • Task1.JPG
    Task1.JPG
    89.1 KB · Views: 3
  • Task1-1.JPG
    Task1-1.JPG
    83.7 KB · Views: 5
  • Task2.JPG
    Task2.JPG
    74.7 KB · Views: 5
  • Task2-1.JPG
    Task2-1.JPG
    67 KB · Views: 5

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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