macro question

jdkaizen

New Member
Joined
Apr 18, 2018
Messages
3
Can I record one macro for all processes I need -- (1) Select entire column [Column V], cut it and insert it somewhere else [Column N]; (2) Sort entire sheet according to header "Transaction Type' [Column N now]; (3) Perform Subtotal at each change in "Transaction Type [Column N now] and function SUM to subtotal at Transaction Quantity [Column O now]?
If not, please enlighten me. Thanks
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I had the 2nd process not working. Every sheet has different number of rows but same number of columns. Sorting doesn't go very well.
Here's my sample code of the macro:
Sub Macro4()
'
' Macro4 Macro
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Range("C1").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("191058017413").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("191058017413").Sort.SortFields.Add Key:=Range( _
"N2:N4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("191058017413").Sort
.SetRange Range("A1:CW10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

Any suggestion?
 
Upvote 0
All that code can be boiled down to this one-liner:

Code:
Worksheets("191058017413").Range("A1").CurrentRegion.Sort key1:=Range("N2"), order1:=xlAscending, Header:=xlYes

But what you are doing beyond that is not clear, especially with regards to why three cells (N2, N3, and N4) are collectively identifying your Sort key field unless they are merged which would be an ill-advised practice under just about any circumstance.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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