Convert VBA to Google Sheets Apps Script

joeyrain

New Member
Joined
Dec 4, 2018
Messages
5
I have a macro formula that i use in excel that I would like to transport the macro to google but it's not working...

What the macro is suppose to do is to sort the columns Based On The Values Of G1 To V1...When When Sorting It Looks At These Values Only So If G1 Has A Value Of 15 And H1 Has A Value Of 10, Then The End Result Of The Sorting Is Only To Switch Columns Of G To H And H To G... We Are Sorting The Columns Not The Rows Based On G1 To V1. The Values In Each Row Stay In The Same Row. We Do Not Want The Rows To Be Sorted We Only Want The Columns To Switch Places Based On The Values Found From G1 To V1

The Macro below works in excel, but it does not translate to google sheets. Can anyone help?



Sub SortML()
'
' SortML Macro
'
' Keyboard Shortcut: Ctrl+z
'
ActiveWorkbook.Worksheets("Draft").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Draft").Sort.SortFields.Add Key:=Range( _
"G1:V1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Draft").Sort.SortFields.Add Key:=Range( _
"G1:V1"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Draft").Sort
.SetRange Range("G1:V56")
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With

For i = 66 To 81
Range(Chr(i) & "1") = i - 65
Next i

End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,215,212
Messages
6,123,651
Members
449,111
Latest member
ghennedy

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