Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to append onto and then sort a pre-existing list

Does anyone know where I can get the source code to do maybe a macro (I
think) that asks the user for an input, which then appends the input to
a pre-existing list and then sorts the new updated list?

Thanks!

*** 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: 1,758
Default Macro to append onto and then sort a pre-existing list

I would think that any suggestion you get would be pretty generic and you'll
have to modify it.

So here's one!

Option Explicit
Sub testme()

Dim NextOpenCellInExistingList As Range
Dim myNewList As Range

With Worksheets("sheet2")
Set NextOpenCellInExistingList _
= .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

Set myNewList = Nothing
On Error Resume Next
Set myNewList = Application.InputBox(Prompt:="Select a range to append", _
Type:=8)
On Error GoTo 0

If myNewList Is Nothing Then
Exit Sub 'user cancelled
End If

myNewList.EntireRow.Copy _
Destination:=NextOpenCellInExistingList

With Worksheets("sheet2")
With .Range("a1:L" & .Cells(.Rows.Count, "A").End(xlUp))
.Sort key1:=.Columns(1), order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End With

End Sub

Lots of assumptions.

Sheet2 contains the original list.

The list always has data in column A (I use it to find the next available row).

Only one row of headers (for the list).

But it might get you started.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Helen Sun wrote:

Does anyone know where I can get the source code to do maybe a macro (I
think) that asks the user for an input, which then appends the input to
a pre-existing list and then sorts the new updated list?

Thanks!

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


--

Dave Peterson
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 can I Append values to an existing excel file. viv New Users to Excel 0 March 21st 07 11:25 AM
Can I sort a list to match a previously existing order? MirCS Excel Worksheet Functions 1 October 11th 06 06:10 PM
How do I paste to append instead of replace existing data? Joel Thomas Excel Discussion (Misc queries) 1 October 3rd 05 01:32 PM
How do I create an excel macro to append to a cell with existing i zola_tiara Excel Discussion (Misc queries) 4 September 14th 05 08:22 PM
How to append existing series? Michael C via OfficeKB.com Charts and Charting in Excel 1 August 20th 05 03:17 PM


All times are GMT +1. The time now is 04:56 AM.

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"