Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
jorgemerizalde
 
Posts: n/a
Default Pls Help, Runtime Error using hlookup


I am getting the exact same error message:

"Run-time error '1004':
Unable to get the HLookup propertyoh the WorksheetFunction class"

when trying to run this code:

Private Sub CBAceptar_Click()
LastCol = Sheets("EI").Range("A1").End(xlToRight).Column
Fecha = CBFechasConsultas.Value
Rango = Sheets("EI").Range(Cells(1, 2), Cells(1, LastCol))
ColFecha = WorksheetFunction.HLookup(Fecha, Rango, 1, False).Column
End Sub

Please help.

P.S. the code is for a command button in a user form I created for a
xls file.


--
jorgemerizalde
------------------------------------------------------------------------
jorgemerizalde's Profile: http://www.excelforum.com/member.php...o&userid=25890
View this thread: http://www.excelforum.com/showthread...hreadid=266415

  #2   Report Post  
Rowan
 
Posts: n/a
Default

The Hlookup worksheet function returns a value and not a range object so it
does not have a column property. If you are wanting to return the column one
way would be:

Private Sub CBAceptar_Click()

Dim rango As Range
Dim lastCol As Integer
Dim fndCol As Range
Dim ColFecha As Integer
Dim fecha As String

lastCol = Sheets("EI").Range("A1").End(xlToRight).Column
fecha = CBFechasConsultas.Value
Set rango = Sheets("EI").Range(Cells(1, 2), Cells(1, lastCol))

Set fndCol = rango.Find(fecha)
If Not fndCol Is Nothing Then
ColFecha = fndCol.Column
End If

End Sub

Hope this helps
Rowan

"jorgemerizalde" wrote:


I am getting the exact same error message:

"Run-time error '1004':
Unable to get the HLookup propertyoh the WorksheetFunction class"

when trying to run this code:

Private Sub CBAceptar_Click()
LastCol = Sheets("EI").Range("A1").End(xlToRight).Column
Fecha = CBFechasConsultas.Value
Rango = Sheets("EI").Range(Cells(1, 2), Cells(1, LastCol))
ColFecha = WorksheetFunction.HLookup(Fecha, Rango, 1, False).Column
End Sub

Please help.

P.S. the code is for a command button in a user form I created for a
xls file.


--
jorgemerizalde
------------------------------------------------------------------------
jorgemerizalde's Profile: http://www.excelforum.com/member.php...o&userid=25890
View this thread: http://www.excelforum.com/showthread...hreadid=266415


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
runtime error '6' overflow don Setting up and Configuration of Excel 1 July 26th 05 02:52 AM
keep the formatting of the cell found using Hlookup Denny Excel Discussion (Misc queries) 4 May 13th 05 09:54 PM
Vlookup and Hlookup Phlogiston2312 Excel Worksheet Functions 1 April 21st 05 04:59 PM
How do I find a value in an array (VLOOKUP? HLOOKUP?) M Skabialka New Users to Excel 2 March 11th 05 02:52 AM
SUMIF - HLOOKUP Combination Mark Excel Worksheet Functions 1 February 4th 05 08:03 PM


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