LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Index and Match - Errors

After being prompted for a target value to be found <= in Col.
"B" (Integers)
I want to return the corresponding date on the same row in Col. "A".
My first suspicion is on my Dims, and the second one is on the syntax
of my Index.
I was trying to find the Match first, then trying to incorporate the
result in the Index. But I failed.
help appreciated
..
Sub FindTargetDate()
Dim WB As Workbook
Dim SH3 As Worksheet
Dim MyPath As String
Dim LastRow, FoundRow As Long
Dim OriginalTarget As Variant
Dim DateRange, TargetRange, FoundDate As Range
MyPath = "C:\1-Work\TestData\"
Set WB = Workbooks.Open(MyPath & "Omega.xls")
Set SH3 = WB.Worksheets("Dates")
SH3.Activate
LastRow = SH3.Cells(Rows.Count, 1).End(xlUp).Row - 1 ' Because there
is a Total row
Set TargetRange = SH3.Range("B2:B") & LastRow ' Error # 1 here. Run
Time error # 1004
Set DateRange = SH3.Range("A2:A") & LastRow
OriginalTarget = InputBox("Target: ")
FoundRow = Application.Match(OriginalTarget, TargetRange, 1) + 1
FoundDate = Application.Index(DateRange, FoundRow) ' Error # 2 Here.
Mismatch ???
SH3.Cells(20, 1) = FoundDate(FoundRow, 1).Value ' Found Date for Found
Row
SH3.Cells(20, 2) = FoundDate(FoundRow, 2).Value ' Found Value <=
OriginalTarget
SH3.Cells(20, 3) = OriginalTarget
FoundDate.Select
With Selection.Font
.Bold = True
.ColorIndex = 5
End With
End Sub
 
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
index(match) Wind Uplift Calculations (match four conditions) JMeier Excel Worksheet Functions 8 August 1st 08 01:45 AM
INDEX / MATCH Formula Errors Ben Excel Discussion (Misc queries) 15 January 6th 08 09:37 PM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
index,match,match on un-sorted data Brisbane Rob Excel Worksheet Functions 3 September 24th 05 10:04 PM
How can I correct color index errors? Mpakateni Excel Programming 2 October 25th 04 03:35 PM


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