![]() |
Range.Text/Value returning the number 3?
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. |
Range.Text/Value returning the number 3?
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 Grant wrote: 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. -- Dave Peterson |
Range.Text/Value returning the number 3?
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. "Dave Peterson" wrote: 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 Grant wrote: 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. -- Dave Peterson |
Range.Text/Value returning the number 3?
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? Grant wrote: 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. "Dave Peterson" wrote: 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 Grant wrote: 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. -- Dave Peterson -- Dave Peterson |
Range.Text/Value returning the number 3?
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 "Grant" wrote in message ... 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. "Dave Peterson" wrote: 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 Grant wrote: 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. -- Dave Peterson |
All times are GMT +1. The time now is 05:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com