Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pal Pal is offline
external usenet poster
 
Posts: 27
Default Combo Box wrong lookup range.

I have a combo Box on one sheet that references a range of data on another
sheet.
The lookup works fine.

But the code attached to it does not. It returns values on the same page the
list box is located
and I want it to pull the data from the linked cell range on the other
sheet.

How can I fix this?
Thanks
Pal


Private Sub ComboBox1_Change()
Cells(11, 2).Value = Mid(ComboBox1.Value, 4)
Cells(12, 2).Value = Mid(ComboBox1.Value, 1, 2)
Cells(13, 2).Value = Cells(ComboBox1.ListIndex + 2, 3)
Cells(14, 2).Value = Cells(ComboBox1.ListIndex + 2, 4)
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Combo Box wrong lookup range.

Add the WITH...END WITH as I did below...change the word target for the name of your sheet where you want to post the data. Add the spot "." before each of the "Cells"

Private Sub ComboBox1_Change()

with Worksheets("target")

.Cells(11, 2).Value = Mid(ComboBox1.Value, 4)
.Cells(12, 2).Value = Mid(ComboBox1.Value, 1, 2)
.Cells(13, 2).Value = Cells(ComboBox1.ListIndex + 2, 3)
.Cells(14, 2).Value = Cells(ComboBox1.ListIndex + 2, 4)

End With

End Sub

--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
"Pal" wrote in message news:cR50c.415449$I06.4623200@attbi_s01...
I have a combo Box on one sheet that references a range of data on another
sheet.
The lookup works fine.

But the code attached to it does not. It returns values on the same page the
list box is located
and I want it to pull the data from the linked cell range on the other
sheet.

How can I fix this?
Thanks
Pal


Private Sub ComboBox1_Change()
Cells(11, 2).Value = Mid(ComboBox1.Value, 4)
Cells(12, 2).Value = Mid(ComboBox1.Value, 1, 2)
Cells(13, 2).Value = Cells(ComboBox1.ListIndex + 2, 3)
Cells(14, 2).Value = Cells(ComboBox1.ListIndex + 2, 4)
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Combo Box wrong lookup range.

Private Sub ComboBox1_Change()

With Worksheets("Sheet2")
.Cells(11, 2).Value = Mid(ComboBox1.Value, 4)
.Cells(12, 2).Value = Mid(ComboBox1.Value, 1, 2)
.Cells(13, 2).Value = .Cells(ComboBox1.ListIndex + 2, 3)
.Cells(14, 2).Value = .Cells(ComboBox1.ListIndex + 2, 4)
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pal" wrote in message
news:cR50c.415449$I06.4623200@attbi_s01...
I have a combo Box on one sheet that references a range of data on another
sheet.
The lookup works fine.

But the code attached to it does not. It returns values on the same page

the
list box is located
and I want it to pull the data from the linked cell range on the other
sheet.

How can I fix this?
Thanks
Pal


Private Sub ComboBox1_Change()
Cells(11, 2).Value = Mid(ComboBox1.Value, 4)
Cells(12, 2).Value = Mid(ComboBox1.Value, 1, 2)
Cells(13, 2).Value = Cells(ComboBox1.ListIndex + 2, 3)
Cells(14, 2).Value = Cells(ComboBox1.ListIndex + 2, 4)
End Sub




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
LOOKUP Function gives wrong results AndreasW Excel Worksheet Functions 4 October 21st 09 12:45 AM
LOOKUP returning wrong values Raghavendran Excel Worksheet Functions 2 April 22nd 09 02:15 PM
Existing form in excel; added a combo box; tabbing wrong now Exceljmruser Excel Discussion (Misc queries) 1 May 28th 08 02:41 PM
Lookup function gives wrong values occasionally [email protected] Excel Discussion (Misc queries) 3 July 1st 06 12:58 AM
Lookup returns wrong value motorjobs Excel Worksheet Functions 5 June 21st 06 11:49 PM


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