Need to transpose cell references

Joined
Jul 14, 2022
Messages
21
Office Version
  1. 2016
Platform
  1. Windows
No idea why I'm having so much trouble with this. I have a bunch of horizontal data in Sheet 1, and want to transpose it vertically into Sheet 2 so that I can use it for a pivot table. I don't want the formulas from Sheet 1, which contain if statements and links to other excel files, I just want the cell references to Sheet 1. Essentially, I want a quick way to fill sheet 2 (let's say 1000R x 1000C) with ='Sheet 1'!A1 in A1, ='Sheet 1'!A2 in B1, ='Sheet 1'!B1 in A2 and so on.

I can't just fill a sheet with the cell references, lock them, then paste and transpose that, as locking a range of cells with F4 doesn't work for formulas like ='Sheet 1'!A1

Thank you
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I have answered my own question. Make sure to run it with calculation on manual, otherwise it'll recalculate the sheet for every cell it fixes.

VBA Code:
Sub AbsoluteReferences()
Dim c As Range
For Each c In Selection
    c.Formula = Application.ConvertFormula(c.Formula, xlA1, , xlAbsolute)
Next
End Sub

Stolen from Locking multiple cell reference formulas at once
 
Upvote 0
Solution
Make sure to run it with calculation on manual, otherwise it'll recalculate the sheet for every cell it fixes.
Note that you can handle that right in the code, like this:
VBA Code:
Sub AbsoluteReferences()
    
    Dim c As Range
    
    Application.Calculation = xlCalculationManual
    
    For Each c In Selection
        c.Formula = Application.ConvertFormula(c.Formula, xlA1, , xlAbsolute)
    Next
    
    Application.Calculation = xlCalculationAutomatic
       
End Sub

and this tweak may even make it run a little faster:
VBA Code:
Sub AbsoluteReferences()
    
    Dim c As Range
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    For Each c In Selection
        c.Formula = Application.ConvertFormula(c.Formula, xlA1, , xlAbsolute)
    Next
    
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
       
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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