Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.Match problem

Sorry for bothering you i'm new in VBA
I am trying to use the MATCH function in VBA to search for a particular hour in a range containing hours and return the matching column number
that give me Error N°13 so thank you for your help

Public Sub test()
With Sheets("F. Regulation")
Dim dt As Double
dt = Sheets("Standard d'engagement").Cells(3, 4)
A = Application.Match(CLng(dt), Range("B2:EP2"), 0)
MsgBox (A)
End With
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application.Match problem

Unfortunately still the same error message
juste to give you clear idea
in
Range("B2:EP2")we have differents hours with hh:mm:ss format
and also in Sheets("Standard d'engagement").Cells(3, 4)
so there is no formula juste typing them manually
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application.Match problem

Sorry that work i'm pointing in the wrong cell thank you I have to use the code with the formula
thank you man (you are my hero )
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Application.Match problem

Hi,

Am Sun, 26 Jul 2015 04:54:21 -0700 (PDT) schrieb Mohamed Elamrani:

Unfortunately still the same error message
juste to give you clear idea
in
Range("B2:EP2")we have differents hours with hh:mm:ss format
and also in Sheets("Standard d'engagement").Cells(3, 4)
so there is no formula juste typing them manually


is it possible that your values are text.
For me the formula:
=MATCH(D3,'F. Regulation'!B2:EP2,1)
works as well as this macro:

Sub test()
Dim dt As Double
Dim A As Long

dt = Sheets("Standard d'engagement").Cells(3, 4)
With Sheets("F. Regulation")
A = Application.Match(dt, .Range("B2:EP2"), 1)
End With
MsgBox (A)

End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application.Match problem

this is my master code ( the first one it was just little one to explain my problem)
in this code the problem persist I don't know why
thank you for your valuable help


Public Sub vol()
With Sheets("F. Regulation")
Dim min, INTL As Long
Dim dt As Double
min = 3000


For INTL = 0 To 20
If CLng(Sheets("Standard d'engagement").Cells(3 + INTL, 4)) < min And Sheets("Standard d'engagement").Cells(3 + INTL, 4) < "" Then
min = CLng(Sheets("Standard d'engagement").Cells(3 + INTL, 4))
i = INTL
End If
Next

dt = CDbl(Sheets("Standard d'engagement").Cells(3 + i, 4))
'Cells(3, WorksheetFunction.Match(Cells(3 + i, 4), Range("B2:EP2"), 0)) = X

For j = 0 To 18
If Cells(j + 3, Application.Match(dt, Range("B2:EP2"), 1)) = "" Then

For i = i To i + 13
Cells(j + 3, Application.Match(CDbl(Sheets("Standard d'engagement").Cells(3 + i, 4)), Range("B2:EP2"), 1)) = X
Next
End If
Next

Sheets("Standard d'engagement").Cells(3 + i, 4).ClearContents
End With
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Application.Match problem

Hi Mohamed,

Am Sun, 26 Jul 2015 05:12:32 -0700 (PDT) schrieb Mohamed Elamrani:

Public Sub vol()
With Sheets("F. Regulation")
Dim min, INTL As Long
Dim dt As Double
min = 3000


For INTL = 0 To 20
If CLng(Sheets("Standard d'engagement").Cells(3 + INTL, 4)) < min And Sheets("Standard d'engagement").Cells(3 + INTL, 4) < "" Then
min = CLng(Sheets("Standard d'engagement").Cells(3 + INTL, 4))


what is min? A time is always smaller than 1 and time is always < min.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application.Match problem

hi
I used Min to initiate the program and to find the smaller hour within different rows in the column XXX
like this
I have

XXX
AT230 12:00 11:00:00
AF1457 14:00 13:00:00
16:00 15:00:00
18:00 17:00:00
20:00 19:00:00
22:00 21:00:00
00:00 23:00:00
02:00 01:00:00
04:00 03:00:00
12:00 11:00:00
14:00 13:00:00
16:00 15:00:00
18:00 17:00:00
20:00 19:00:00
22:00 21:00:00
00:00 23:00:00
02:00 01:00:00
04:00 03:00:00
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
application.match and value problem Cbrehm Excel Discussion (Misc queries) 0 February 12th 11 04:34 PM
Application.Match problem rstroughair Excel Programming 4 April 27th 09 06:05 PM
Application.WorksheetFunction.Match problem Carl Brehm Excel Worksheet Functions 1 January 9th 05 02:08 PM
Application.Match problem Tom Ogilvy Excel Programming 1 September 22nd 04 07:45 PM
Application.Match problem Marcotte A Excel Programming 0 September 22nd 04 06:37 PM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"