Hi Manik
Here's a VBA solution for an automatic numbering.
1. From the sheet rightclick the sheet-tab and choose "View code"
2. Copy the below code and paste it to the righthand window.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim CheckRange As Range
On Error Goto Finito
Set CheckRange = Range("A1:C12, D16, F16:H16")
If Union(Target, CheckRange).Address = Union(CheckRange,
CheckRange).Address Then
Application.EnableEvents = False
For Each Cell In Target
Call Numbering(Cell)
Next Cell
End If
Finito:
Application.EnableEvents = True
End Sub
3. Enter the cells in question in CheckRange instead of
Range("A1:C12, D16, F16:H16")
4. Choose from the menu Insert > Module
5. Copy the below code and paste it to the righthand window.
Sub Numbering(CheckCell As Range)
'Leo Heuser, 18-7-2003
Dim CheckCellValue As String
Dim Counter As Long
Dim FindChr10 As Long
Dim MaxNumberOfDigits As Long
CheckCellValue = CheckCell.Value
FindChr10 = 1
Counter = 1
MaxNumberOfDigits = 3 ' Numbering from 1 to 999. Used
'to pad the numbers with blanks to make them (almost with
'a proportional font

line up under each other.
Do While InStr(FindChr10, CheckCellValue, Chr(10))
FindChr10 = InStr(FindChr10, CheckCellValue, Chr(10))
Counter = Counter + 1
CheckCellValue = Left(CheckCellValue, FindChr10) & _
String(MaxNumberOfDigits - Len(Mid(Str(Counter), 2)), " ") & _
Counter & ". " & Mid(CheckCellValue, FindChr10 + 1)
FindChr10 = FindChr10 + 1
Loop
CheckCellValue = String(MaxNumberOfDigits - 1, " ") & _
"1. " & CheckCellValue
CheckCell.Value = CheckCellValue
End Sub
6. Go to the sheet with <Alt><F11> and save the workbook.
When you enter your lists, with <Alt><Return> as described
by Gord, in the cells of
Set CheckRange = Range("A1:C12, D16, F16:H16")
they will be automatically numbered.
Another option is to insert the below code in a module,
and call it from the sheet with a button.
Sub Numbering2()
'Leo Heuser, 18-7-2003
Dim CheckCell As Range
Dim CheckCellValue As String
Dim Counter As Long
Dim FindChr10 As Long
Dim MaxNumberOfDigits As Long
Set CheckCell = ActiveCell
CheckCellValue = CheckCell.Value
FindChr10 = 1
Counter = 1
MaxNumberOfDigits = 3 ' Numbering from 1 to 999. Used
'to pad the numbers with blanks to make them (almost with
'a proportional font

line up under each other.
Do While InStr(FindChr10, CheckCellValue, Chr(10))
FindChr10 = InStr(FindChr10, CheckCellValue, Chr(10))
Counter = Counter + 1
CheckCellValue = Left(CheckCellValue, FindChr10) & _
String(MaxNumberOfDigits - Len(Mid(Str(Counter), 2)), " ") & _
Counter & ". " & Mid(CheckCellValue, FindChr10 + 1)
FindChr10 = FindChr10 + 1
Loop
CheckCellValue = String(MaxNumberOfDigits - 1, " ") & _
"1. " & CheckCellValue
CheckCell.Value = CheckCellValue
End Sub
1. Enter the list in a random cell
as described above.
2. Select the cell
3. Push the button
4. The list is numbered.
--
Best Regards
Leo Heuser
MVP Excel
Followup to newsgroup only, please.