Update Sheet Based On Entry In Different Sheet

BeanCounters

New Member
Joined
Aug 7, 2011
Messages
8
Hi All,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Need a little help re-working a code. I need to have data entered in my data entry worksheet update my client list worksheet if the client name does not already exist in the client list worksheet.


The code I posted below worked great when I was using a combobox with Data Validation. I have since changed to using a combobox with ActiveX so I could use the autocomplete feature. Can anyone advise on how to get this code to work with cbo ActiveX?


Am I correct in thinking it has something to do with the “Set rngDV=Cells.SpecialCells(xlCellTypeAllValidation)? I have the code inside of my data entry worksheet if that means anything.
<o:p></o:p>
<o:p></o:p>
<o:p>
Code:
Option Explicit
' Developed by Contextures Inc.
' [URL="http://www.contextures.com"]www.contextures.com[/URL]</o:p>
<o:p>Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ws As Worksheet
Dim str As String
Dim i As Integer
Dim rngDV As Range
Dim rng As Range</o:p>
<o:p>If Target.Count > 1 Then Exit Sub
Set ws = Worksheets("Client List")
 
If Target.Row > 1 Then
  On Error Resume Next
  Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
  On Error GoTo 0
  If rngDV Is Nothing Then Exit Sub
 
  If Intersect(Target, rngDV) Is Nothing Then Exit Sub
 
  str = Target.Validation.Formula1
  str = Right(str, Len(str) - 1)
  On Error Resume Next
  Set rng = ws.Range(str)
  On Error GoTo 0
  If rng Is Nothing Then Exit Sub
 
  If Application.WorksheetFunction _
    .CountIf(rng, Target.Value) Then
    Exit Sub
  Else
    i = ws.Cells(Rows.Count, rng.Column).End(xlUp).Row + 1
    ws.Cells(i, rng.Column).Value = Target.Value
    rng.Sort Key1:=ws.Cells(1, rng.Column), _
      Order1:=xlAscending, Header:=xlNo, _
      OrderCustom:=1, MatchCase:=False, _
      Orientation:=xlTopToBottom
  End If</o:p>
<o:p>End If</o:p>
<o:p>End Sub
</o:p>
<o:p></o:p>
<o:p></o:p>

To further complicate my life, boss also wants this to verify if we really want to add new client to the list. Perhaps a msgbox that asks “ ‘new client name’ is not in the list. Do you want to add?” ('new client name' would show as the name you just entered). Just need that extra step to prevent misspellings and tabbing out of the field without checking their entry.
<o:p></o:p>

Thank you for any help you can provide.
<o:p></o:p>

Sincerely,<o:p></o:p>
Julie<o:p></o:p>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,586
Messages
6,179,707
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top