Macro and Triangle

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
How to write Macro to automatically link the latest diagonal to the column which is shown in the table? Thanks


45 23 12 44 45 56 56
56 12 23 89 46 46
68 10 45 78 78
91 23 56 56
79 45 45
52 52
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
Hi!
Do you mean like this?
Book1
ABCDEFGH
145231244455656
2561223894646
36810457878
491235656
5794545
65252
Sheet2
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Triangle()
    lastrow = Range("a65536").End(xlUp).Row
    maxcol = lastrow
    <SPAN style="color:#00007F">For</SPAN> i = lastrow<SPAN style="color:#00007F">To</SPAN> 1<SPAN style="color:#00007F">Step</SPAN> -1
        Range(Cells(i, maxcol + 2), Cells(i, maxcol + 2)).Value = Range(Cells(i, maxcol - i + 1), Cells(i, maxcol - i + 1))
    <SPAN style="color:#00007F">Next</SPAN> i<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>
 

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
Thanks, I will test tomorrow.
By the way, can you tell me how you pasted the Excel format you showed here on the board?
Good night.
Best regards.
Dennis
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
Theres a dowlloadable file below this post, name colo's html maker. its an add in to make java script of your worksheet.
you can use that to post your sheet here in this board.
Good nyt! Have a peaceful nyt!
 

Yogi Anand

MrExcel MVP
Joined
Mar 12, 2002
Messages
11,454
Hi Dennis:

Here is a formula based solution ...
Book1
ABCDEFGHI
14523124445565656
256122389464646
3681045787878
49123565656
579454545
6525252
Sheet4


I know you asked for a macro based solution, so the preceding formula-based solution may or may not be of any interest to you.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,323
Messages
5,769,454
Members
425,549
Latest member
Bartekelese

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
Top