Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting A Row Into A Data Table
I have a table of data sorted by column A. Is there a way
to insert a row of data into this table in its proper sorted position (so that after the insert operation the data is still sorted)? The method I am using now is to append the row of data at the bottom of the table, then resort the table. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting A Row Into A Data Table
Jeffrey,
It can be done but putting it at the bottom and doing a resort is probably quicker and easier. -- sb "Jeffrey" wrote in message ... I have a table of data sorted by column A. Is there a way to insert a row of data into this table in its proper sorted position (so that after the insert operation the data is still sorted)? The method I am using now is to append the row of data at the bottom of the table, then resort the table. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting A Row Into A Data Table
Sub AAtester2()
Dim rng As Range Dim res As Variant Dim newValue as Long NewValue = 1 If NewValue < Range("A2") Then Rows(2).Insert Range("A2") = NewValue Else Set rng = Range(Cells(2, 1), _ Cells(Rows.Count, 1).End(xlUp)) res = Application.Match(NewValue, rng, 1) If Not IsError(res) Then rng(res + 1).EntireRow.Insert rng(res + 1).Value = NewValue End If End If End Sub If these are dates, you will need to adjust Sub AAtester3() Dim rng As Range Dim res As Variant Dim newValue As Date newValue = DateSerial(2003, 1, 10) If newValue < Range("A2") Then Rows(2).Insert Range("A2") = newValue Else Set rng = Range(Cells(2, 1), _ Cells(Rows.Count, 1).End(xlUp)) res = Application.Match(CLng(newValue), rng, 1) If Not IsError(res) Then rng(res + 1).EntireRow.Insert rng(res + 1).Value = newValue End If End If End Sub -- Regards, Tom Ogilvy Jeffrey wrote in message ... I have a table of data sorted by column A. Is there a way to insert a row of data into this table in its proper sorted position (so that after the insert operation the data is still sorted)? The method I am using now is to append the row of data at the bottom of the table, then resort the table. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting a table within a large worksheet | Excel Discussion (Misc queries) | |||
inserting a calculated field in a pivot table. | Excel Discussion (Misc queries) | |||
Inserting formular in Table | Excel Discussion (Misc queries) | |||
I would require help in inserting formulas in Pivot Table please. | Excel Discussion (Misc queries) | |||
Pivot Table Macro not inserting all data fields | Excel Discussion (Misc queries) |