Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell formatting when pulling into VB


I have an excel spreadsheet that im pulling into a VB flexgrid wit
ADODB.

But i have a collumn that has a header and sub header and then belo
that is several records of times.
When it pulls from that table, it formats EVERYTHING in that collumn a
a time thus nullifying the header and sub header.

I tried adding 'imex=1' to the extrended proporties but then "2:00 PM
becomes .58333333...

is there a happy medium? some way i can have each cell formatte
individually

--
Skeletonha
-----------------------------------------------------------------------
Skeletonhat's Profile: http://www.excelforum.com/member.php...fo&userid=1569
View this thread: http://www.excelforum.com/showthread.php?threadid=27223

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Cell formatting when pulling into VB

Skeletonhat wrote ...

I have an excel spreadsheet that im pulling into a VB flexgrid with
ADODB.

But i have a collumn that has a header and sub header and then below
that is several records of times.
When it pulls from that table, it formats EVERYTHING in that collumn as
a time thus nullifying the header and sub header.

I tried adding 'imex=1' to the extrended proporties but then "2:00 PM"
becomes .58333333...


Sounds like you are binding the flexgrid to an ADODB recordset (I
don't usually bother because, unlike the DataGrid, the flexgrid
doesn't support strict data typing, editing, etc) or adding the data
in one hit e.g.

MSFlexGrid1.Clip = rs.GetString(adClipString):

If you add the data to the flexgrid yourself e.g. by looping through
the recordset, you have control over the format of the text.

It also sounds like you consider the heading and subheading to be data
items in their own right (headings are usually metadata rather than
data), presumably of 'text' data type. You will always have a
fundamental problem mixing data types and you've seen both of Jet's
solutions: 1) cast the values as text (which affects the formatting of
your times) and 2) null the values that don't fit the majority type
(which knocks out your headings).

Assuming you have some idea of the approximate cell address of your
heading, you can use them in the table name. For example, say you are
currently using HDR=NO in the connection and you SQL is:

SELECT F1 FROM [Sheet1$];

If you know your headers in cells A1 and A2, then keep the HDR=NO and
select the headers (text) using:

SELECT F1 AS MyHeadings FROM [Sheet1$A1:A2];

and similarly select the data (times) using:

SELECT F1 AS MyTimes FROM [Sheet1$A3:A65535];

(note: will not fetch all the rows on the sheet, rather just those in
the UsedRange).

If you know your headers are in rows 1 and two and are in the leftmost
column (i.e. F1) but you are not exactly sure if the table starts in
column A or not, then be a bit more vague with the cell addresses e.g.
for headers:

SELECT F1 AS MyHeadings FROM [Sheet1$1:2];

for the data:

SELECT F1 AS MyTimes FROM [Sheet1$3:65535];

Jamie.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling data from one cell to another Ivan Koh[_2_] Excel Discussion (Misc queries) 3 May 4th 09 06:53 PM
pulling data and formatting [email protected] Excel Discussion (Misc queries) 1 August 22nd 07 05:03 PM
Pulling text from a cell jnasr Excel Worksheet Functions 3 November 9th 06 04:44 PM
Pulling a Letter from a cell and filling another cell with info nick s Excel Worksheet Functions 16 November 28th 05 04:10 AM
pulling certain data out of a cell D richardson Excel Worksheet Functions 6 May 13th 05 06:10 PM


All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"