Copy formulas into Columns

wlbamc

Board Regular
Joined
Apr 19, 2016
Messages
99
Office Version
  1. 2016
I have copied my formulas from excel into notepad and now want to copy them into another spreadsheet but cannot work out if or how I can copy them all at once so that they go across the line not down the column, so each formula in a different column on the same line. Due to the name ranges on both workbooks being the same and the fact that my formulas are reading another tab on the workbook I am unable to just copy the tab, unless someone knows how I can do that as well. I hope this makes sense
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I have subroutine that I keep in my personal.xlb file for doing exactly this. It swaps rows to columns or columns to row . To get it to work on column of data; select the rows that you want transposed, then run the macro, select the top left cells where you want the formulae pasted, then click OK
VBA Code:
Sub Rowtocolform()
'
' to swap rows to columns, select the formula you want to swap, then run the macro,
' the macro will ask you where you want to put the data, and it will copy the data to that
' location using the location as The top left corner of the array, but with the rows swapped for columns
Dim outarr() As Variant
Dim plac As Range
firstrow = Selection.Row
rc = Selection.Rows.Count - 1
LastRow = Selection.Row + rc

Dim ActSheet As Worksheet
Dim SelRange As Range
Set ActSheet = ActiveSheet
Set SelRange = Selection
rowc = Selection.Rows.Count
colc = Selection.Columns.Count
ReDim outarr(1 To colc, 1 To rowc)
For i = 1 To rowc
For j = 1 To colc
outarr(j, i) = SelRange(i, j).Formula

Next j
Next i

'plact = Selection.Address
    Dim oRangeSelected As Range
    On Error Resume Next
    Set oRangeSelected = Application.InputBox("Please select a cell for the top left of the array!", _
                                              "SelectARAnge Demo", Selection.Address, , , , , 8)
    If oRangeSelected Is Nothing Then
 '       MsgBox "It appears as if you pressed cancel!"
    Else
'        MsgBox "You selected: " & oRangeSelected.Address(External:=True)
   
    firstrow = oRangeSelected.Row
    firstcol = oRangeSelected.Column
   
   
    Range(Cells(firstrow, firstcol), Cells(firstrow + colc - 1, firstcol + rowc - 1)) = outarr
    End If

mm = 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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