Excel 2002: Any quick way for transposing formulas?
Or don't use that macro, rather use this one from I believe John
Walkenbach,,,,,,,,,maybe Tom Ogilvy.
You pick the range to transpose and the range to paste to.
Transposes without adding the Absolute $ signs.
Sub Transpose_Formulas()
Dim SRange As Range, dCell As Range
Dim sCell As Range, i As Integer, J As Integer
Dim str As String
'get input ranges. default box is filled by use of text
'variable set to the selected address
str = Selection.Address(False, False)
Application.ScreenUpdating = True
On Error Resume Next
Set SRange = Application.InputBox(prompt:= _
"Select the range of cells to be transposed." & Chr(10) & Chr(10) _
& "If cells do not have Formulas, Sub will end!.", _
Type:=8, Default:=str)
If Not SRange.HasFormula Then
MsgBox "Cells do not contain formulas"
End
Else
If SRange.HasFormula Then
Set dCell = Application.InputBox(prompt:= _
"Select the top left cell of the output location.", _
Type:=8)
If dCell Is Nothing Then End
On Error GoTo 0
'set single cell references for use in the next step
Set sCell = SRange.Cells(1, 1)
Set dCell = dCell.Cells(1, 1)
'loop through all cells, working backward to the top left cell
For i = SRange.Rows.Count - 1 To 0 Step -1
For J = SRange.Columns.Count - 1 To 0 Step -1
If i 0 Or J 0 Then
'do this for all but the first cell
sCell.Offset(i, J).Cut _
Destination:=dCell.Offset(J, i)
Else
'do top corner last. Otherwise references are changed
sCell.Cut Destination:=dCell
End If
Next J
Next i
End If
End If
End Sub
Gord Dibben MS Excel MVP
On Fri, 4 Apr 2008 07:49:01 -0700, Gary''s Student
wrote:
First enter Dibben's macro:
Sub Absolute()
Dim cell As Range
For Each cell In Selection
If cell.HasFormula Then
cell.Formula = Application.ConvertFormula _
(cell.Formula, xlA1, xlA1, xlAbsolute)
End If
Next
End Sub
Then select the cells and run the macro.
|