Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default vLookup and Line Breaking

Greetings all,
I have a worksheet where cell B8 and B10 perform a vLookup based on a data
validation in B6:

=IF(B6="","",(VLOOKUP(B6,Position,2,0)))
IF(B6="","",VLOOKUP(B6,AD_Groups,2,0))

I have the following code in place to perform a line break after each comma
in the returned value. It works great the first time, but then anytime I
change or add something to any cell in the range B1:B10 it adds another line
break to B8 and B10. Anything after B10 is fine and doesn't affect the
previous cells. I guess what I'm asking is if there is a way to alter this
code (which I found in a previous posting, just altered my range to B1) so
that it only happens if B6 is selected and changed? And only affects cells
B8 and B10, so any other cells that may have commas are unaffected?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As Range
Dim t As Range
Set t = Target
Set a = Range(Range("B1"), Cells(Rows.Count, 1).End(xlUp))
Dim s1 As String
Dim s2 As String
s1 = ","
s2 = s1 & Chr(10)
If Intersect(t, a) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each t In a
t.Value = Replace(t.Value, s1, s2)
Next t
Application.EnableEvents = True
End Sub

Also if I try to clear out my cells to start over, my formula's disappear and
I can't add them back. Each time I try the cell just clears itself out
again. I have to alter my range to something like A1, then I can add my
formulas again.

As always I appreciate any help I can get.
--
Jon M.
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
Line Break Vlookup Jon M. Excel Worksheet Functions 2 March 2nd 10 06:30 PM
Breaking a line within a formula - HELPHELP PLEASE Shirley Excel Discussion (Misc queries) 2 December 17th 09 08:40 PM
Vlookup only taking first line of data Michael Dinning Excel Discussion (Misc queries) 6 June 23rd 06 01:12 PM
Vlookup returns line number MrDan8 Excel Worksheet Functions 1 June 12th 06 04:57 PM
connector line between vlookup and list. mostakimm Excel Discussion (Misc queries) 0 January 26th 06 05:26 PM


All times are GMT +1. The time now is 07:32 AM.

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"