Determining Format of Column\Cell in VB using OLE 
Author Message
 Determining Format of Column\Cell in VB using OLE

How can I determine the Format/Type of an Excel     Column\Cell  using OLE
in VB?

Thanks in Advance

Doug



Thu, 24 Nov 2005 22:14:16 GMT  
 Determining Format of Column\Cell in VB using OLE
Doug,

Specificially what do you mean by "Format/Type" of a column?
Number Format? Font Style?


Quote:
> How can I determine the Format/Type of an Excel     Column\Cell
using OLE
> in VB?

> Thanks in Advance

> Doug



Thu, 24 Nov 2005 22:20:35 GMT  
 Determining Format of Column\Cell in VB using OLE
Hi Doug,

    If you mean you want to determine what kind of data a cell contains,
there's no simple call. First off, every cell in a column can contain a
different data type, so there's no reliable way to determine the data type
of a column. Maybe all the cells contain the same type of data, maybe they
don't. For individual cells, you just have to use the "Is" functions to test
for various conditions until you find the one that returns True. For
example:

Sub TestRange(rngToTest As Excel.Range)
    If IsNumeric(rngToTest.Value) Then
        ''' It's a number.
    ElseIf IsDate(rngToTest.Value) Then
        ''' It's a date.
    ElseIf IsError(rngToTest.Value) Then
        ''' It's an error.
    ElseIf IsEmpty(rngcell.Value) Then
        ''' It's a blank cell.
    Else
        ''' Otherwise it's probably a string.
    End If
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


Quote:
> How can I determine the Format/Type of an Excel     Column\Cell  using OLE
> in VB?

> Thanks in Advance

> Doug



Thu, 24 Nov 2005 22:24:41 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Determine format of a cell (using formula)

2. Move cell row format to column cell format

3. Using VB to change columns and formatting in a query

4. How do I copy a sheet and retaining the cell format and layout using through VB

5. Formatting cells using VB code

6. Using one cell's contents to determine which other cell to reference

7. Comparing columns to determine lookup cell

8. Format Column of Active Cell between First/Last Cell

9. How to determine if a text entered in a cell exceed the current column width

10. Searching one column via OLE/VB


 
Powered by phpBB® Forum Software © phpBB Group