Dave showed you the corrected code - what the correction should be.
Using the WITH statement, both range references were preceded by a period,
so they reference the same worksheet (Proceso)
P25 should definitely reference the same sheet where ListaMejorOpcion is
located. As Norie said, the unqualified Range("P25") refers to the sheet
containing the code. (actually, he said the active sheet, which is
incorrect. In a sheet module, it refers to the sheet containing the code -
this is a problem you may encounter over and over as you convert your code).
--
Regards,
Tom Ogilvy
"jose luis" wrote
in message ...
Thanks Norie and Dave,
I realize and learn what my mistake was. Dave says be careful with the
P25 Cell, Should i put a Defined name to the cell instead?
Thanks again for your responses, They help a lot, I learn a lot....
Jose Luis
Dave Peterson Wrote:
I think I'd be careful with that P25 cell, too:
Private Sub ComboBox1_Change()
Application.ScreenUpdating = False
with Sheets("Proceso")
.Range("ListaMejorOpcion").Sort Key1:=.Range("P25"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
end with
Application.ScreenUpdating = True
End Sub
Norie wrote:
Don't use select.
Code:
--------------------
Private Sub ComboBox1_Change()
Application.ScreenUpdating = False
Sheets("Proceso").Range("ListaMejorOpcion").Sort
Key1:=Range("P25"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom
Application.ScreenUpdating = True
End Sub
--------------------
--
Norie
------------------------------------------------------------------------
Norie's Profile:
http://www.excelforum.com/member.php...o&userid=19362
View this thread:
http://www.excelforum.com/showthread...hreadid=374156
--
Dave Peterson
--
jose luis
------------------------------------------------------------------------
jose luis's Profile:
http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=374156