auto format cell to enter data alphabet in column

G

Guest

I have 2 columns on my worksheet. 1st is alphabetical list of projects, 2nd
are the identifying project numbers. when i enter a new project name at the
top of the first column, i want it to enter directly into the correct
alphabetical cell in the column
 
G

Guest

Assume columns E & F with E1 and F1 empty and ready for data entry. The
following routine will run as soon as you have entered data in both E1 and
F1. It will sort the data and leave a new empy area in E1 and F1:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("E1:F1"), Target) Is Nothing Then
Exit Sub
End If
If IsEmpty(Range("E1")) Or IsEmpty(Range("F1")) Then
Exit Sub
End If
Application.EnableEvents = False
Range("E:F").Sort Key1:=Range("E1")
Range("E1:F1").Insert Shift:=xlDown
Application.EnableEvents = True
End Sub


This is worksheet code - don't put in a standard module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top