vba, flip it over the pattern

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hello people
with this code,
VBA Code:
Sub rur()
      For i = 1 To 5
            For j = 1 To 5
                  Cells(i, j) = i
            Next
      Next
End Sub
I got this
1618707858247.png


how can I get
1618707948542.png

Thank for reading.
Please, some help in this.
 
Another way using a formula (copy across)
Code:
=INDEX(A$1:A$5,COUNTA(A1:A$5))
IAssuming the output will go into cells A1:E5, here is another formula that will work. Place this formula in cell A1 and copy across to cell E1, then copy A1:E1 down to Row 5...
Excel Formula:
=6-ROW()
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Thank you Mr. Rick.
I'm guessing your goal is to understand looping, but if your goal is simply to produce the output you showed no matter the method, then you could consider this...
VBA Code:
Sub MonteCarlo2012()
  [A1:E5] = [{5;4;3;2;1}]
End Sub
My goal is to understand the logic before typing any for loop, all the process behind the loops, no just copy and write for = 1 to something etc etc, reason why I am not using any formula, " or " the very popular statement "with_____end with", I really appreciate your input.
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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