View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default "value" works in sheet, not vba

Mike,

The default property of a range object is .Value:

loanorig = Sheets("main").Range("b2")
loanorigrow = Application.Match(loanorig.Value,
Sheets("loan").Range("a1:a3745"), 0)


So, your code sets loanorig to the Value of Cell B2 on worksheet "main"

Try this:

loanorig = Sheets("main").Range("B2").Value
loanorigrow = Application.Match(loanorig, _
Sheets("loan").Range("a1:a3745"), 0)

HTH,
Bernie
MS Excel MVP
"mike allen" wrote in message
...
why would a formula on a spreadsheet work, while reproducing it in code
doesn't? i must be writing code incorrectly.

spreadsheet formula:
=MATCH(VALUE(B2),loan!$A$1:$A$3745,0)

code:
loanorig = Sheets("main").Range("b2")
loanorigrow = Application.Match(loanorig.Value,
Sheets("loan").Range("a1:a3745"), 0)

any thoughts? i am really having problems w/ comparing and transforming
text to values and vice versa. ALL I AM TRYING TO DO IS MATCH THINGS THAT
LOOK ALIKE, but am failing miserably b/c one may be a number, the other

text
(text only b/c it is a formula result---from a number of all things).
reformatting cells does no good. if i can at least get the above problem
worked out, i can get by for now. thanks, (disdraught w/ excel) mike

allen