2 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Jul 21, 2011 at 11:19 PM
Jul 21, 2011 at 11:19 PM
I was trying to write a formula it gets complicated.
I am giving you a macro
in sheet2 row no. 1 is for header row
so data starts only from row 2
e.g below
heng1 grade data
consultant senior
programmer junior
now try this macro
BUT BE CAREFUL THE SPELLING OF CONSULTANT, PROGRAMMER ETC AND ALSO JUNIOR AND SENIOR MUST BE EXACT IN BOTH THE SHEETS. If there is mistake there macro will give error.
I am giving you a macro
in sheet2 row no. 1 is for header row
so data starts only from row 2
e.g below
heng1 grade data
consultant senior
programmer junior
now try this macro
Sub test()
Dim r As Range, prog As String, grade As String, findr As Range, findc As Range, c As Range
Dim x As Range
With Worksheets("sheet2")
Set r = Range(.Range("A2"), .Cells(Rows.Count, "A").End(xlUp))
For Each c In r
prog = c.Value
MsgBox prog
grade = c.Offset(0, 1).Value
MsgBox grade
With Worksheets("sheet1")
Set findr = .Cells.Find(what:=prog, lookat:=xlWhole)
Set findc = .Cells.Find(what:=grade, lookat:=xlWhole)
Set x = Application.Intersect(.Rows(findr.Row), .Columns(findc.Column))
MsgBox x
End With
c.Offset(0, 2) = x
Next c
End With
End Sub
BUT BE CAREFUL THE SPELLING OF CONSULTANT, PROGRAMMER ETC AND ALSO JUNIOR AND SENIOR MUST BE EXACT IN BOTH THE SHEETS. If there is mistake there macro will give error.