Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel #value! error

Status
Not open for further replies.

xenomage

Programmer
Jun 27, 2001
98
SG
Hi all,

PLEASE HELP!!!

i'm using SQL Server and trying to place a string into an excel file like so.

objExcel.Range("A1") = rstMain("str")

This works fine if the string "rstMain('str')" is shorter than 255. But, if the string is more than 255, the cell in excel becomes a stupid #value!.

How can i solve this. PLEASE HELP!!

xenomage
 
Don't you just love Excel? Boy-o-boy, I do.

Anyway, I went to Excel and recorded a macro of selecting a range of cells, and then changing the format of those cells to text. Here's what it recorded:

Range("A1:A27").Select
Selection.NumberFormat = "@"

I would try doing that on the range of cells where you think you might be putting values >255 in length, and see if that clears the problem up.

If it doesn't, I fear you'll just need to monkey around w/ the format of cells until you find a combination that works w/ it, record the appropriate macro, and use it.

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Hi Paul,

that method i had tried and it doesn't work but thanks anyway.

Found that the problem was becoz of stupid sql server. What i did was this.

strTemp = rstMain("str")
objSheet.Range("A1") = strTemp

and it actually WORKS!! stupid right??

xenomage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top