try this:
Private Sub CommandButton1_Click()
' ----This sub will insert formulas in sheet2 referencing sheet1 _
but in reverse order in each column.
' Eg:
'Data in Sheet1:
'A1=5.500 B1=0.275
'A2=5.625 B2=0.125
'A3=5.750 B3=0.000
'A4=5.875 B4= -0.125
'Data in Sheet2:
'A1=Sheet1!A4 B1=Sheet1!B4
'A2=Sheet1!A3 B2=Sheet1!B3
'A3=Sheet1!A2 B3=Sheet1!B2
Dim Rw As Integer
Dim i As Integer
Dim j As Integer
Dim flipform As String
Dim LastColumn As Integer
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Sheet2.Cells.ClearContents ' clear sheet2
'-----------Determine last used column------------------------
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Columns.
LastColumn = Sheet1.Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
End If
'-----------reference sheet1 cells into sheet2 ------------------------
Sheet1.Select
For j = 1 To LastColumn
Range(Cells(1, j).Address, Range(Cells(65536,
j).Address).End(xlUp)).Select
Rw = Selection.Rows.Count 'Determine last used Row in column
For i = 1 To Rw
flipform = "=sheet1!" & Sheet1.Cells(i, j).Address
If Sheet1.Cells(i, j).Value <> "" Then 'If
sheet1 cell is empty do not copy
Sheet2.Cells((Rw - i + 1), j).Formula =
flipform
Else
Sheet2.Cells((Rw - i + 1), j).Value = ""
End If
Next i
Next j
EndMacro:
Sheet1.Cells(1, 1).Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub