Copying cell contents from a referred cell that is in reference to a "find" cell

Z

ZX210

I have a program which will export report information to Excel. Th
problem is that if a field in the host program was not used then i
will not show in the report which is exported to Excel. (No nul
fields). This produces an Excel sheet in which the cell contents var
with every export.

That is just a little background information. Let me describe th
actual problem. Suppose a set of two columns is formed where column
is a list of names and column B is a list of numerical values. I hav
written code that will find the appropriate name and select that th
associated cell, but I cannot get my program to shift over to column
so that I can copy the numerical value associated with the found name.
I have fooled with this for a very long time and am assuming that ther
is either an object or a method of reference that I have not stumble
upon.

The numerical value also changes with each export so I cannot use th
find command for the value. I have tried working with addresses
relative addresses and a couple of other odds and ends, but I canno
put the entire puzzel together. If this sounds like something yo
might know a little about please email me (e-mail address removed) fo
sample code and etc. Thank
 
J

J.E. McGimpsey

Not exactly sure what you're doing, but this may help:

Dim found As Range
Dim myValue As Double
Set found = Columns(1).Cells.Find( _
What:="myname", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not found Is Nothing Then _
myValue = found.Offset(0, 1).Value

substitute your desired name (or, more likely a variable) for
"myname". Note that no selection is needed - you can work directly
with the range object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top