Hi everyone,
I just started trying to teach myself how to use VBA/Macros ect. I have a workbook (attached) that I am trying to flip a range at will (vertically). I found a VBA script that enables me to do this, but I have to first press [Alt] + [F11] which opens up the module and then [F5] to run it. It then brings me to my sheet to select a range. I would like it to remain on the sheet and have a quicker access without losing my place.
Column A will always be changing and I need to flip certain segments of column B for relabeling. This will show me what the previous location was and what to change it to.
The script is as follows:
Sub FlipColumns()
'Updateby20131126
Dim Rng As Range
Dim WorkRng As Range
Dim Arr As Variant
Dim i As Integer, j As Integer, k As Integer
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Arr = WorkRng.Formula
For j = 1 To UBound(Arr, 2)
k = UBound(Arr, 1)
For i = 1 To UBound(Arr, 1) / 2
xTemp = Arr(i, j)
Arr(i, j) = Arr(k, j)
Arr(k, j) = xTemp
k = k - 1
Next
Next
WorkRng.Formula = Arr
End Sub
Is there an easy way I can make this happen? Thanks for your time on this.
Bookmarks