Simple Loop VBA Code

rozek

New Member
Joined
Aug 11, 2021
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hi. I'm trying to do a loop with this. I hope that someone can help me on this and I could learn doing this on my own for other project. Thank you

Y.Sheets("Field").Cells(6, 48) = Y.Sheets("Field").Cells(5, 6)
Y.Sheets("Field").Cells(20, 48) = Y.Sheets("Field").Cells(6, 6)
Y.Sheets("Field").Cells(34, 48) = Y.Sheets("Field").Cells(7, 6)
Y.Sheets("Field").Cells(48, 48) = Y.Sheets("Field").Cells(8, 6)
Y.Sheets("Field").Cells(62, 48) = Y.Sheets("Field").Cells(9, 6)
Y.Sheets("Field").Cells(76, 48) = Y.Sheets("Field").Cells(10, 6)
Y.Sheets("Field").Cells(90, 48) = Y.Sheets("Field").Cells(11, 6)
Y.Sheets("Field").Cells(104, 48) = Y.Sheets("Field").Cells(12, 6)

Will this work? Seems not
For i = 5 to 12
For j = 1 to 8 step 13
Y.Sheets("Field").Cells(j, 48) = Y.Sheets("Field").Cells(i, 6)
next j
next i
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I don't know what Y represents, but try...
VBA Code:
n = 5
For j = 6 To 104 Step 14
Sheets("Field").Cells(j, 48) = Sheets("Field").Cells(n, 6)
n = n + 1
Next j
 
Upvote 0
Solution
I don't know what Y represents, but try...
VBA Code:
n = 5
For j = 6 To 104 Step 14
Sheets("Field").Cells(j, 48) = Sheets("Field").Cells(n, 6)
n = n + 1
Next j
Thank you Michael. It works. :)(y)
 
Upvote 0

Forum statistics

Threads
1,224,833
Messages
6,181,240
Members
453,026
Latest member
cknader

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