Range.Text/Value returning the number 3?

G

Grant

Hi,

I am using VB.Net (Interop) and when I try to retrieve a value from a cell
it returns the number 3 instead of the actual value that is in the cell.

It happens for some of my cells, but others seem to work fine - I have no
idea what is happening.

I use Range("B4").Value or Range("B4").Text and also tried
Range("B4").FormulaR1C1, but still get that strange number 3 turning up.

Any ideas?

Thanks in advance,

Grant.
 
D

Dave Peterson

Are you sure you're picking up B4 from the correct worksheet?

I'd qualify the range to see if that helped.

workbooks("someworkbook").worksheets("somesheet").range("b4").value
 
G

Grant

Hi Dave,

I'm absolutely sure that it's picking up the correct worksheet, etc.

I already specify the worksheet name followed by the range.

It will pickup the correct values just around the cell B4 correctly, but
returns 3 for that cell - and it also does the same thing for some other
cells. I only have one workbook open at the time, and don't specify the
workbook name anywhere.

So if I tried to get the value in B3 it gives me the correct value, etc.

I know it seems strange, but it happens for only some cells, and in
different worksheets (not just one of them).

Any help on this would be great - I'm not sure if there is some sort of bug
retrieving values from VB.Net using the Interop?

Thanks,

Grant.
 
D

Dave Peterson

I've never used VB.Net--but I have screwed up using VBA (so that's why I asked).

And I've seen merged cells do strange things (using VBA). Any chance?
 
N

NickHK

Grant,
As Dave says, these error normally occur because you are not retrieving a
value from the location you think.
What do you get for
Range("B4").Parent.name
Range("B4").Parent.Parent.name

What does this give ?
Range("B4").Value="Test Value"
Msgbox Range("B4").Value

NickHK
 

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