#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 159
Default Data validation

I'm updateing data validation list and I useing this VBA code and that
updates my list. The problem I'm haveing is I want the data to go to the end
of the list. Can anyone help me with this VBA code. Table is my list name.
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), Target.Value)
Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
ws.Range("table").Sort Key1:=ws.Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End If

End Sub
Thanks for your help,
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,480
Default Data validation

Hi Larry

If you want the value to remain at the end of your list, remove the Sort
routine.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), _
Target.Value) Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
End If
End If

End Sub

--
Regards
Roger Govier

"Larry" wrote in message
...
I'm updateing data validation list and I useing this VBA code and that
updates my list. The problem I'm haveing is I want the data to go to the
end
of the list. Can anyone help me with this VBA code. Table is my list name.
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), Target.Value)
Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
ws.Range("table").Sort Key1:=ws.Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End If

End Sub
Thanks for your help,


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 159
Default Data validation

Thanks Roger
Can you tell which one is the sort routine

"Roger Govier" wrote:

Hi Larry

If you want the value to remain at the end of your list, remove the Sort
routine.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), _
Target.Value) Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
End If
End If

End Sub

--
Regards
Roger Govier

"Larry" wrote in message
...
I'm updateing data validation list and I useing this VBA code and that
updates my list. The problem I'm haveing is I want the data to go to the
end
of the list. Can anyone help me with this VBA code. Table is my list name.
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), Target.Value)
Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
ws.Range("table").Sort Key1:=ws.Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End If

End Sub
Thanks for your help,



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 159
Default Data validation

Roger Thanks for the help it now works.
One more question can I deled the data useing this same VBA code.
Thanks Again for your help

"Roger Govier" wrote:

Hi Larry

If you want the value to remain at the end of your list, remove the Sort
routine.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), _
Target.Value) Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
End If
End If

End Sub

--
Regards
Roger Govier

"Larry" wrote in message
...
I'm updateing data validation list and I useing this VBA code and that
updates my list. The problem I'm haveing is I want the data to go to the
end
of the list. Can anyone help me with this VBA code. Table is my list name.
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim i As Integer

Set ws = Worksheets("table")
If Target.Column = 4 And Target.Row 1 Then
If Application.WorksheetFunction.CountIf(ws.Range("ta ble"), Target.Value)
Then
Exit Sub
Else
i = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = Target.Value
ws.Range("table").Sort Key1:=ws.Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End If

End Sub
Thanks for your help,



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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Data Validation Update Validation Selection PCreighton Excel Worksheet Functions 3 September 11th 07 03:32 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM


All times are GMT +1. The time now is 07:15 PM.

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"