Thread
:
vlookup in vb
View Single Post
#
2
Posted to microsoft.public.excel.programming
Dave Peterson
external usenet poster
Posts: 35,218
vlookup in vb
Option Explicit
Sub testme()
Dim res As Variant
Dim LookupRng As Range
Dim myCell As Range
With Worksheets("database")
Set LookupRng = .Range("b:b")
End With
Set myCell = Worksheets("main").Range("B1")
res = Application.Match(myCell.Value, LookupRng, 0)
If IsError(res) Then
MsgBox "Not found!"
Else
With LookupRng.Parent.Cells(res, "CB")
If IsNumeric(.Value) Then
.Value = .Value - 1
Else
MsgBox "Not numeric!"
End If
End With
End If
End Sub
wrote:
Ok here is what I am trying to do. I have a worksheet called "main"
and another called "database''
I want to lookup the value in cell B1 in "main'' worksheet in the
"database'' worksheet which is in column A.
Once found I want it to go to column CB in that same row and subtract
1 from the value there.
I know how to use vlookup to find a value but I figured to subtract 1
from that value a must use a macro, and I am stumped
How can I do this
Thanks in advance
--
Dave Peterson
Reply With Quote
Dave Peterson
View Public Profile
Find all posts by Dave Peterson