Formula to Transpose Diagonals using OFFSET

exceluser2007

Active Member
Joined
Nov 21, 2007
Messages
365
Hi All,

I have the following sample data.

Excel Workbook
BCDEFGHIJKL
3Quarter0123Sep-01Dec-01Mar-02Jun-02
4Sep-012438487824222525
5Dec-01223745383736
6Mar-0225364845
7Jun-022578
Sheet1


Using the table on the left, I have manually created the desired table on the right.

It basically transposes the daigonals in the first triangulated table into a reflection of the original table.

I'm sure that this can be easily automated using a OFFSET formula on cell C5 (starting cell) in the left-hand table.

Could anyone please assist with this formula approach.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Running
Code:
Sub x()
Dim rng As Range
Set rng = Range("b4:b7")
Dim Answ, i As Double, j As Double
ReDim Answ(1 To 5)
For i = 1 To 5
     Answ(i) = Application.Transpose(rng.Offset(, i - 1).Value)
     Answ(i) = y(Answ(i))
Next
Answ = Application.Transpose(Application.Transpose(Answ))
Range("a21").Resize(UBound(Answ, 1), UBound(Answ, 2)) = Answ
End Sub
Sub Function
Code:
Function y(v As Variant)
Dim ii As Double
Dim tmp As Variant
Dim cnt As Double
cnt = UBound(v)
ReDim tmp(1 To UBound(v))
For ii = UBound(v) To 1 Step -1
     If CStr(v(ii)) <> "" Then
     tmp(cnt) = v(ii)
     cnt = cnt - 1
     End If
Next
y = tmp
End Function
 
Upvote 0
theozz, sincere thanks for your help. I appreciate it.

However, as I would like to send this worksheet to other people, who may not be familiar with VBA, i was wondering how to do it using an OFFSET formula which could be dragged across to give the reflection. of the original triangle.

Sincerely appreciate your help, but if you or any other MrExceler's could please explain how to do it using formulae that would help me with this problem, and my develop understanding of Excel in general.

Thanks,
 
Upvote 0
Good for you. No need for VBA when Excel-native solutions exist.

The solution requires knowing how many empty cells there are in each column. We'll put that information in H. So, in H4 enter the formula =COUNTIF(INDEX($C$4:$F$7,0,ROW()-ROW($H$3)),"")

Then, in I4 enter the formula =IF(COLUMN()-COLUMN($I$3)<$H4,"",INDEX($C$4:$F$7,COLUMN()-COLUMN($I$3)+1-$H4,ROW()-ROW($I$3)))

Copy I4 to J4:L4. Copy H4:L4 to rows 5:7.

theozz, sincere thanks for your help. I appreciate it.

However, as I would like to send this worksheet to other people, who may not be familiar with VBA, i was wondering how to do it using an OFFSET formula which could be dragged across to give the reflection. of the original triangle.

Sincerely appreciate your help, but if you or any other MrExceler's could please explain how to do it using formulae that would help me with this problem, and my develop understanding of Excel in general.

Thanks,
 
Upvote 0
Tushar, sincere thanks for your encouraging and detailed response, works great!

It is always nice to understand and appreciate the true power of Excel through such function based approaches.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

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