Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Data Validation Update Validation Selection

Update Validation Selection I have been to www.contextures.com and downloaded
DV0022, this is exactly what I wish to achieve when a selection in the list
is updated the data file updates to the new description. The problem is when
I add a new item to the list it updates every blank cell in the data file
colum with the new value added to the list, I don't want it to update all
blank cells when new item added to the look-up list. Please help with what I
am doing wrong.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,979
Default Data Validation Update Validation Selection


You can add code to check for an empty string in the old value:

If strOld < "" Then
wsData.Columns("B:B").Replace What:=strOld, _
Replacement:=strNew, LookAt:=xlPart, _
SearchOrder:=xlByRows
End If


PCreighton wrote:
Update Validation Selection I have been to www.contextures.com and downloaded
DV0022, this is exactly what I wish to achieve when a selection in the list
is updated the data file updates to the new description. The problem is when
I add a new item to the list it updates every blank cell in the data file
colum with the new value added to the list, I don't want it to update all
blank cells when new item added to the look-up list. Please help with what I
am doing wrong.



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,480
Default Data Validation Update Validation Selection

Hi

Debra's code was based upon a fixed range for Fruitlist, whereas I suspect
yours is Dynamic.
One way of dealing with the problem would be to test for a null string for
Old and goto the exit handler. I have marked where the inserted lines
appear.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errHandler

Dim rng As Range
Dim strOld As String
Dim strNew As String
Dim wsData As Worksheet
Dim wsLists As Worksheet

Set wsLists = Sheets("Lists")
Set wsData = Sheets("Data")
Set rng = wsLists.Range("FruitList")

If Intersect(Target, rng) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
strNew = Target.Value
Application.Undo
strOld = Target.Value

' inserted lines
If strOld = "" Then
Target.Value = strNew
GoTo exitHandler
End If
' end of inserted lines

Target.Value = strNew
wsData.Columns("B:B").Replace What:=strOld, _
Replacement:=strNew, LookAt:=xlPart, _
SearchOrder:=xlByRows
Application.EnableEvents = True
End If

exitHandler:
Application.EnableEvents = True
Exit Sub

errHandler:
MsgBox "Change could not be completed"
GoTo exitHandler
End Sub

--
Regards
Roger Govier



"PCreighton" wrote in message
...
Update Validation Selection I have been to www.contextures.com and
downloaded
DV0022, this is exactly what I wish to achieve when a selection in the
list
is updated the data file updates to the new description. The problem is
when
I add a new item to the list it updates every blank cell in the data file
colum with the new value added to the list, I don't want it to update all
blank cells when new item added to the look-up list. Please help with what
I
am doing wrong.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Data Validation Update Validation Selection

Thank you Roger & Debra worked like a charm.
both worked the other change I made was to make my Range Name Dynamic.

"Roger Govier" wrote:

Hi

Debra's code was based upon a fixed range for Fruitlist, whereas I suspect
yours is Dynamic.
One way of dealing with the problem would be to test for a null string for
Old and goto the exit handler. I have marked where the inserted lines
appear.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errHandler

Dim rng As Range
Dim strOld As String
Dim strNew As String
Dim wsData As Worksheet
Dim wsLists As Worksheet

Set wsLists = Sheets("Lists")
Set wsData = Sheets("Data")
Set rng = wsLists.Range("FruitList")

If Intersect(Target, rng) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
strNew = Target.Value
Application.Undo
strOld = Target.Value

' inserted lines
If strOld = "" Then
Target.Value = strNew
GoTo exitHandler
End If
' end of inserted lines

Target.Value = strNew
wsData.Columns("B:B").Replace What:=strOld, _
Replacement:=strNew, LookAt:=xlPart, _
SearchOrder:=xlByRows
Application.EnableEvents = True
End If

exitHandler:
Application.EnableEvents = True
Exit Sub

errHandler:
MsgBox "Change could not be completed"
GoTo exitHandler
End Sub

--
Regards
Roger Govier



"PCreighton" wrote in message
...
Update Validation Selection I have been to www.contextures.com and
downloaded
DV0022, this is exactly what I wish to achieve when a selection in the
list
is updated the data file updates to the new description. The problem is
when
I add a new item to the list it updates every blank cell in the data file
colum with the new value added to the list, I don't want it to update all
blank cells when new item added to the look-up list. Please help with what
I
am doing wrong.




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
Data Validation with selection Lee New Users to Excel 4 September 5th 07 11:17 PM
Data Validation with multiple table selection SteveMax Excel Discussion (Misc queries) 3 May 11th 07 02:49 PM
update data validation list with new entries?? cjtj4700 Excel Discussion (Misc queries) 10 December 12th 05 01:00 AM
Data validation named range update Phil Deem Excel Discussion (Misc queries) 3 July 16th 05 03:55 AM
Data Validation list selection question Bob Wall Excel Worksheet Functions 2 December 4th 04 04:51 PM


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