Forum

how to understand a...
 
Notifications
Clear all

how to understand a recorded macro - please!

2 Posts
2 Users
0 Reactions
107 Views
(@tinak)
Posts: 39
Trusted Member
Topic starter
 

Hello, I have a recorded macro worksheet created by someone else, and I am trying to understand the sort steps/actions seen as below. (part of macro)

There is a full list sheet containing all the information, e.g. emails, address, etc, recorded macro segment them to a new tab in the same workbook. The person recorded it also has a worksheet "full list trimmed" in a tab (every cell =trim('full list'!), I can't find this sheet in the recorded macro, not sure why it is created?

Sheets("Emails").Select
Cells.Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Emails").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Emails").Sort.SortFields.Add Key:=Range( _
"S2:S20000"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Emails").Sort
.SetRange Range("A1:AF20000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Can anyone help me with it? many thanks!

 
Posted : 20/06/2018 9:46 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Tina,

When this macro was recorded, a sort was the only action applied to Emails sheet. Most probably, the other sheet has TRIM formulas, but these formulas were added before recording a macro, that's why it's not in the recorded macro, obviously only actions executed after you start the recorder are recorded.

You can try that yourself, start recorder, add a formula to a cell then copy it to the right and down, you'll see how the recorded macro looks.

 
Posted : 23/06/2018 12:04 am
Share: