Formula to search code or letters in another cell and return it in different cell

kiebel

New Member
Joined
Feb 10, 2017
Messages
5
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]G[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[TD]V[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][TABLE="width: 78"]
<tbody>[TR]
[TD="class: xl65, width: 78"]Course code[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD]COM 121[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]COM 122[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]COM 123[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]COM 124[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]CREDIT UNIT[/TD]
[TD][/TD]
[TD]CW[/TD]
[TD]EX[/TD]
[TD]TS[/TD]
[TD]GRADE[/TD]
[TD]CW[/TD]
[TD]EX[/TD]
[TD]TS[/TD]
[TD]GRADE[/TD]
[TD]CW[/TD]
[TD]EX[/TD]
[TD]TS[/TD]
[TD]GRADE[/TD]
[TD]CW[/TD]
[TD]EX[/TD]
[TD]TS[/TD]
[TD]GRADE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]NAME[/TD]
[TD]MATRIC. NO.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 111"]
<tbody>[TR]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 111"]
<tbody>[TR]
[TD]Column to search[/TD]
[/TR]
[TR]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Remaining courses to clear[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]KIEBEL, Manfred[/TD]
[TD]HM14/2016[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD]25[/TD]
[TD]F[/TD]
[TD]30[/TD]
[TD]20[/TD]
[TD]50[/TD]
[TD]CD[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Abs[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Rpt COM 121, COM 123, COM 122[/TD]
[TD]Rpt COM 121, COM 123[/TD]
[/TR]
</tbody>[/TABLE]

CELL F4, J4, N4 AND R4 ,These Cells search cell S4 and indicate Abs if the content correspond with the course code in cell C2, G2, K2 or O2

CELL T4 should indicate 'Nil' if all course code are cleared or courses code that are not cleard should now appear here


PLEASE I NEED FORMULA TO SOLVE THIS PROBLEM
 
Last edited by a moderator:

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
This method uses regular formulas in the grade to return an "Abs" if it's a required course.When you get a grade for the course, overwrite the formula with a grade. You put the call for the User Defined Function below in the right most column of each student row. It sees which courses are required (in second most right hand column), searches for the course name in row 1, and looks at the grade associated with that course. If it's not completed, or failed, it returns the courses that need to be completed. If they are all completed, it returns "Nil". The function may need some tweaking depending on how the spreadsheet is built. Are there only 4 course columns? Are there header columns for the required courses and needed courses column? Are they always the same columns?

You'll need one of these for each course. This one goes in F4 for the course in C1. Change C to whatever column has the course number. Change the S to whatever column has the required courses.
Code:
=IF(IFERROR(FIND($C$1,S4),0)>0,"Abs","")


Put this code in a Module:

Code:
Function compareCourses() As String
Dim RqdCourses() As String
Dim Rng As Range
Dim x As Long
[COLOR=#00ff00]'what row is the function in[/COLOR]
x = Application.Caller.Row
[COLOR=#00ff00]'find the last used column in row one.[/COLOR]
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
[COLOR=#00ff00]'if there are headers in the two Rpt columns, you'll need this to find the last course, if not, use LastCol in it's place.[/COLOR]
lastCourse = Cells(1, lastCol - 2).End(xlToLeft).Column
[COLOR=#00ff00]'turn off events[/COLOR]
Application.EnableEvents = False
[COLOR=#00ff00]'set the beginning text[/COLOR]
temp = "Rpt "
[COLOR=#00ff00]'put the required courses into an array[/COLOR]
RqdCourses = Split(Replace(Cells(x, lastCol - 1), "Rpt ", ""), ", ")
[COLOR=#00ff00]    'loop thru each required course[/COLOR]
    For i = 0 To UBound(RqdCourses)
[COLOR=#00ff00]        'if there is something in that item[/COLOR]
        If Trim(RqdCourses(i)) <> "" Then
[COLOR=#00ff00]            'set the columns to find the course names[/COLOR]
            With Sheets("Sheet1").Range(Cells(1, 3), Cells(1, lastCourse))
[COLOR=#00ff00]                'search for the course name[/COLOR]
                Set Rng = .Find(What:=RqdCourses(i), _
                                After:=.Cells(.Cells.Count), _
                                LookIn:=xlValues, _
                                LookAt:=xlWhole, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlNext, _
                                MatchCase:=False)
[COLOR=#00ff00]                'where the course name is found[/COLOR]
                If Not Rng Is Nothing Then
[COLOR=#00ff00]                    'if the course name is Abs or a grade of F.  Add more Or statements for other failing grades.[/COLOR]
                    If Rng.Offset(x - 1, 3) = "Abs" Or Rng.Offset(x - 1, 3) = "F" Then
[COLOR=#00ff00]                        'write the course name[/COLOR]
                        temp = temp & Rng.Value & ", "
                    End If
                End If
            End With
        End If
Next
[COLOR=#00ff00]'get rid of the last comma and space[/COLOR]
If Right(temp, 2) = ", " Then temp = Left(temp, Len(temp) - 2)
[COLOR=#00ff00]'if there are no courses listed[/COLOR]
If Len(temp) < 5 Then
[COLOR=#00ff00]    'return Nil[/COLOR]
    compareCourses = "Nil"
Else
[COLOR=#00ff00]    'otherwise return the course names.[/COLOR]
    compareCourses = temp
End If
[COLOR=#00ff00]'turn events back on[/COLOR]
Application.EnableEvents = True
End Function

Then, in the last column, put:
Code:
=compareCourses()
 
Upvote 0
The course(s) may be Nil for a particular student or 1 to 12 maximum
I will try the code and get back to you
 
Upvote 0
I input =compareCourses(F4,J4,N4,R4,S4) in Cell T4 and it gives me[TABLE="width: 97"]
<tbody>[TR]
[TD="class: xl66, width: 97, align: center"]#NAME?
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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