I'm VERY inexperienced with VBA, but trying to build a simple spreadsheet to facilitate data entry and management for my sister.
Basically, it's a 12 column contacts data . The userform is working nicely for the data entry, and data lookups. I expect to have a data modification (change addresses, preferences, etc.) up and running by the end of the weekend. All the work is done on a single sheet.
My problem is that I have a list box which presents the source of the contact, such as Facebook, church, mailing, etc.) A new source can be added to the bottom of the list that supports the list box. All this works really well, for a guy who doesn't know what he's doing. Unfortunately, I want more... I want to sort that list which in Cell BA1 and down.
The data has a header (Contact Source) which must remain at the top. I have read about a hundred pages of VBA coding online on this topic, copying and pasting the code when possible. No matter how I try to edit things, I continue to get one of several errors when I get to the sorting function.
I would REALLY appreciate any proper coding help that can be offered.
This is the coding I have gotten to so far. As I said, it all works well up to the sort command. I have used so many options offered by the web sites I visited, I have no idea what belongs in the code and what doesn't.
Private Sub AddSource_Click()
Dim NewSource As Range
Dim SortRange As Range
Worksheets("list").Activate
Set SortRange = Range(("ba2"), Range("ba2").End(xlDown))
Set NewSource = Worksheets("list").Range("ba1").End(xlDown).Offset(1, 0)
NewSource.Value = InputBox("Add new contact source", "New Contact Source", "Enter name of venue or contact source here.")
SortRange.Select
Set SortRange = Range(("ba1"), Range("ba2").End(xlDown))
SortRange.Select
Range.Sort.Range(("ba1"), Range("ba1").End(xlDown)), Header:=xlYes
Thank you all in advance.
Basically, it's a 12 column contacts data . The userform is working nicely for the data entry, and data lookups. I expect to have a data modification (change addresses, preferences, etc.) up and running by the end of the weekend. All the work is done on a single sheet.
My problem is that I have a list box which presents the source of the contact, such as Facebook, church, mailing, etc.) A new source can be added to the bottom of the list that supports the list box. All this works really well, for a guy who doesn't know what he's doing. Unfortunately, I want more... I want to sort that list which in Cell BA1 and down.
The data has a header (Contact Source) which must remain at the top. I have read about a hundred pages of VBA coding online on this topic, copying and pasting the code when possible. No matter how I try to edit things, I continue to get one of several errors when I get to the sorting function.
I would REALLY appreciate any proper coding help that can be offered.
This is the coding I have gotten to so far. As I said, it all works well up to the sort command. I have used so many options offered by the web sites I visited, I have no idea what belongs in the code and what doesn't.
Private Sub AddSource_Click()
Dim NewSource As Range
Dim SortRange As Range
Worksheets("list").Activate
Set SortRange = Range(("ba2"), Range("ba2").End(xlDown))
Set NewSource = Worksheets("list").Range("ba1").End(xlDown).Offset(1, 0)
NewSource.Value = InputBox("Add new contact source", "New Contact Source", "Enter name of venue or contact source here.")
SortRange.Select
Set SortRange = Range(("ba1"), Range("ba2").End(xlDown))
SortRange.Select
Range.Sort.Range(("ba1"), Range("ba1").End(xlDown)), Header:=xlYes
Thank you all in advance.