Hello - I had an earlier thread which I think I placed too much code thus making it difficult for someone to help. Here is a short version. The Vlookup Line generates an error . . would appreciate any help . . .can't seem to find the problem . . .
Code:
Dim MySh As WorksheetSet MySh = Sheets("Detail_R11")
Dim MyRange As Range, c As Range
Dim MyCol As Integer, MyRow As Integer
If MsgBox("Would you like to run your code?", vbYesNoCancel + vbQuestion, "GSA: NATIONAL CAPITAL REGION") = vbYes Then
Dim LastR As Integer
MySh.Activate
LastR = ActiveSheet.Range("b" & Rows.Count).End(xlUp).Row
MySh.Cells(1, 1).Select
'FIND COLUMN WITH "ORGANIZATION" HEADING
Do
ActiveCell.Offset(0, 1).Select
Loop Until ActiveCell.Value = "Organization"
MyCol = ActiveCell.Column
MyRow = 1
'COLUMN FOR "ORGANIZATION"
Set MyRange = Range(Cells(MyRow, MyCol), Cells(LastR, MyCol))
'LOOP THOUGHT AND BEGIN TO MAKE CHANGES TO "ORGANIZATION" COLUMN
For Each c In MyRange
If c.Value = "P11B0001" And c.Offset(0, 1) <> "" Then _
c.Value = Application.WorksheetFunction.VLookup(c.Offset(0, 1).Value, ThisWorkbook.Names("MyNamedRange").RefersToRange, 2)
Next c
End If