Macro To Lookup Value In Array And Return Value From Second Row

rameezl17

Board Regular
Joined
Mar 6, 2018
Messages
105
Hi Everyone,

I currently have this macro

Sub Find_Phase()
Dim found As Range
Set found = Sheets("1").Rows("17:18").Find(what:=Sheets("Report").Cells(2, 2).Value, LookIn:=xlValues, lookat:=xlWhole)
If found Is Nothing Then
Else
Sheets("Report").Cells(5, 3) = found.Row
End If
End Sub

So far it returns the row number to my "Report" Sheet, however I need the macro to return the value in row 18 that is underneath the row 17 value...

for an example, if the value is found in sheets("1") row 17 column G i need the value in my "Report" sheet to be from sheets("1") row 18 column G.

Im not sure if this macro is the right direction but i am stuck
 
Its an addition to this code so now I can add one more criteria to lookup, but it will be a different range
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
now i need to search the project hours worked of the name in Cell A2 of each of the projects listed in Column A5:A based on the date in Cell B2


the name range in the lookup tabs is in column F20:F24
The hours range in the lookup tabs is in Range H20:DJ24
 
Last edited:
Upvote 0
How about
Code:
Sub Find_Phase()
   Dim Cl As Range, Fnd As Range, Fnd2 As Range
   Dim Ws As Worksheet
   
   Set Ws = Sheets("Report")
   For Each Cl In Ws.Range("A5", Ws.Range("A" & Rows.Count).End(xlUp))
      With Sheets(Mid(Cl.Value, InStr(1, Cl.Value, " ") + 1))
         Set Fnd = .Rows(17).Find(Ws.Range("B2").Value, , xlValues, xlWhole, , , , , False)
         If Fnd Is Nothing Then Exit For
         Cl.Offset(, 2).Value = Fnd.Offset(1)
         Set Fnd2 = .Range("F20:F24").Find(Ws.Range("A2").Value, , , xlWhole, , , False, , False)
         If Not Fnd2 Is Nothing Then Cl.Offset(, 3).Value = Intersect(Fnd2.EntireRow, Fnd.EntireColumn).Value
      End With
   Next Cl
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hey Fluff theres an issue when I create a new project which creates a new Tab... it gives me a subscript out of range on this line

With Sheets(Mid(Cl.Value, InStr(1, Cl.Value, " ") + 1))
 
Upvote 0
What is the sheet name of the new project & what is the project name?
 
Upvote 0
Well the way the file works is that each project is given a ID # and that is what the tab is called... the list starts with ID 1 and for everytime that a project is created the tab will be +1 of the previous tab. So Currently I have "1","2","3","4", and the list will continue growing once more projects are added
 
Upvote 0
What is the project name that gave the error?
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top