View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Creating xla file to clear junk and sort reqd data

I recorded a macro which gave me this....

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11-10-2008 by PT
'

'
Range("A:A,C:C,E:E,F:F").Select
Range("F1").Activate
Selection.Delete Shift:=xlToLeft
Columns("A:B").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

... then I removed unnecessary Select's, Activate and Selection and ended up
with this

Sub DelAndSort()
Range("A:A,C:C,E:F").Delete
Columns("A:B").Sort Key1:=Range("A2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

I would have though a little macro like this would fit into your
Personal.xls. Look at alt-F8 to set a shortcut, or look at Application.OnKey
in help.

Regards,
Peter T

wrote in message
...
Hello.

I am doing a manual task everyday to remove columns which are not
required and sort required columns after seggregating alphabets from
number. I am seeking help to create an .xla file (Addin) which can
allow me to do this task in one shortcut key (CTRL+ALT+G)

My data is as follows A1:F13

Junk1 Code Junk2 Remark Junk3 Junk4
Junk L Junk 2-F Junk Junk
Junk K Junk 2-E Junk Junk
Junk F Junk 1-F Junk Junk
Junk A Junk 1-A Junk Junk
Junk I Junk 2-C Junk Junk
Junk J Junk 2-D Junk Junk
Junk C Junk 1-C Junk Junk
Junk B Junk 1-B Junk Junk
Junk H Junk 2-B Junk Junk
Junk D Junk 1-D Junk Junk
Junk G Junk 2-A Junk Junk
Junk E Junk 1-E Junk Junk

I want an output which would look like as follow (A1:B13)

Code Remark
A 1-A
B 1-B
C 1-C
D 1-D
E 1-E
F 1-F
G 2-A
H 2-B
I 2-C
J 2-D
K 2-E
L 2-F

Above is just a sample data. The rows and columns could be more. Code
and Remark will always be in column B and D respectively.

Can somebody help?