Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a sortable column

I would like to create a macro that would insert a column into a
spreadsheet which I can then sort by. Not being familar with creating
macros, I am looking for any guidance on how to get started. What the
macro needs to do is as follows:

1) insert a column into the active spreadsheet as the
first column.

2) starting with the active cell in this newly inserted
column, populate it with A1,B1,C1,A2,B2,C2,A3,B3,C3,
and so on until there is no more data in the second
column.

I'll also need to know how to save this macro so that I can use it over
again.

Any help on this is greatly appreciated.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Creating a sortable column

Sub SortMyData()
Dim rng As Range, i As Long, J As Long
Dim cell As Range
Columns(3).Insert
Cells(1, 3).Value = "HeaderC"
Set rng = Range(Cells(2, 2), _
Cells(Rows.Count, 2).End(xlUp))
i = 1
J = 64
For Each cell In rng
J = J + 1
cell.Offset(0, 1).Value = Chr(J) & i
If J = 67 Then
J = 64: i = i + 1
End If
Next
Cells(1, 3).CurrentRegion.Sort _
Key1:=Cells(1, 3), Order1:=xlAscending, _
Header:=xlYes

Columns(3).Delete
End Sub

--
Regards,
Tom Ogilvy


"rsine" wrote in message
...
I would like to create a macro that would insert a column into a
spreadsheet which I can then sort by. Not being familar with creating
macros, I am looking for any guidance on how to get started. What the
macro needs to do is as follows:

1) insert a column into the active spreadsheet as the
first column.

2) starting with the active cell in this newly inserted
column, populate it with A1,B1,C1,A2,B2,C2,A3,B3,C3,
and so on until there is no more data in the second
column.

I'll also need to know how to save this macro so that I can use it over
again.

Any help on this is greatly appreciated.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert clip art into a cell and have it sortable econ Excel Discussion (Misc queries) 2 June 7th 07 08:11 PM
Online worksheet and remain sortable? guyfromage Excel Discussion (Misc queries) 0 October 12th 06 02:06 PM
make worksheets sortable lauriB Excel Worksheet Functions 1 October 4th 06 01:47 AM
how to enter sortable dates before 1900 AlanH Excel Discussion (Misc queries) 1 August 25th 06 06:19 PM
Sortable list of checkboxes nvtd1 Excel Discussion (Misc queries) 0 December 19th 05 10:00 PM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"