Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default auto add to list

excel2003

I got this from ozgrid.
Private Sub Worksheet_Change(ByVal Target As Range)

Dim lReply As Long

If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$D$1" Then
If IsEmpty(Target) Then Exit Sub
If WorksheetFunction.CountIf(Range("MyNames"), Target) = 0
Then
lReply = MsgBox("Add " & Target & " to list", vbYesNo +
vbQuestion)
If lReply = vbYes Then

Range("MyNames").Cells(Range("MyNames").Rows.Count + 1, 1) = Target
End If
End If
End If
End Sub

How do I use this on a User Form

I created the list on "Lists" sheet in H9:H10
List name is ModSN
I substituted my range and list name in the above code and refers to
formula, but it doesn't work. I used my textbox's name in place of the
address.

Here's what I have placed in the module where the ComboBox code is.
(Doubleclicked the combo box and pasted the code and modified)

Private Sub frmProcessDataEntry_Change(ByVal Target As Range)

Dim lReply As Long

If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "cbModSN" Then
If IsEmpty(Target) Then Exit Sub
If WorksheetFunction.CountIf(Range("ModSN"), Target) = 0 Then
lReply = MsgBox("Add " & Target & " to list", vbYesNo +
vbQuestion)
If lReply = vbYes Then
Range("ModSN").Cells(Range("ModSN").Rows.Count +
1, 1) = Target
End If
End If
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default auto add to list

On 14 May, 22:30, Gizmo wrote:

Dim lReply As Long

* * If Target.Cells.Count 1 Then Exit Sub
* * * * If Target.Address = "cbModSN" Then
* * * * * * If IsEmpty(Target) Then Exit Sub
* * * * * * * * If WorksheetFunction.CountIf(Range("ModSN"), Target) = 0 Then
* * * * * * * * * * lReply = MsgBox("Add " & Target & " to list", vbYesNo +
vbQuestion)
* * * * * * * * * * * * If lReply = vbYes Then
* * * * * * * * * * * * * * Range("ModSN").Cells(Range("ModSN").Rows.Count +
1, 1) = Target
* * * * * * * * * * * * End If
* * * * * * * * End If
* * * * End If
End Sub


(I don't have Excel on this computer so can't try these)
Are the ranges (modSN and cbmodSN) named ranges or range objects? In
either case, try them without the quote marks and Range() functions.


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
auto fill or auto search from a list or drop-down list??????? Joe H.[_2_] Excel Discussion (Misc queries) 9 August 29th 08 12:56 AM
Auto-List-Pop-Up Jim May[_3_] Excel Discussion (Misc queries) 0 May 2nd 08 07:21 PM
Auto filtering vs Date List Create List torajudo Excel Worksheet Functions 2 January 29th 06 10:30 AM
Auto check list box Paul Excel Programming 1 April 1st 05 12:49 AM
Scrolling through Auto List members list Hari Prasadh Excel Programming 3 January 30th 05 05:27 AM


All times are GMT +1. The time now is 08:20 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"