I'm trying to create a formula that will check if a cell has a value in Column B and then input a vlookup in column A. As a standard formula it would look like
=VLOOKUP(B2,'Date Shown'!A:E,7,FALSE)
I would want the lookup value to change based on the cell thats originally being check. I have the below formula that can check and add a value to the adjacent cell, which i tried to modify for a vlookup, but don't have the knowledge to create a vlookup properly. I appreciate any help, thanks!
Option Explicit
Sub Macro1()
Dim r As Range
Dim LastRow As Long
With Sheets("Date Hidden")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For Each r In .Range("B2:B" & LastRow)
If r.Value <> "" Then
r.Offset(0, -1).result = Application.WorksheetFunction.VLookup(Sheets("Date Hidden").Range("A2"), Sheets("Date Shown")A:G, 7, False)
End If
Next r
End With
End Subs
Date Shown sheet:
Column A // Column G
Jane / / 10/1/17
Date Hidden Sheet
Column A //Column B
(empty) // Jane
Sheets("Date Shown")A:G
should beSheets("Date Shown").Range("A:G")
– Scott Cranerr.Offset(0, -1).result =
tor.Offset(0, -1).Value =
? I don't believeresult
is a valid property. – TotsieMae