PC Review


Reply
Thread Tools Rate Thread

Determine cells with "General" number format

 
 
PBcorn
Guest
Posts: n/a
 
      6th Aug 2009
I need a VB expression so I can test for cells with a "general" format as
opposed to "number" format. Is there a property statement which will do this?

Thanks
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      6th Aug 2009
Sub Test()
Dim vGen As Variant
Dim cel As Range
Dim rng As Range

Set rng = Range("A1:A10")

vGen = rng.NumberFormat = "General"

If IsNull(vGen) Then
MsgBox "at least one cell is General but not all"
For Each cel In rng
Debug.Print cel.Address, cel.NumberFormat
Next
ElseIf vGen = True Then
MsgBox "all cells are General"
Else
MsgBox "no cells are General"
End If

End Sub

Regards,
Peter T

"PBcorn" <(E-Mail Removed)> wrote in message
news:24E2263C-E2FD-49EB-9D22-(E-Mail Removed)...
>I need a VB expression so I can test for cells with a "general" format as
> opposed to "number" format. Is there a property statement which will do
> this?
>
> Thanks



 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Aug 2009
If Range("A1").NumberFormat = "General" Then
'do something
End If

If this post helps click Yes
---------------
Jacob Skaria


"PBcorn" wrote:

> I need a VB expression so I can test for cells with a "general" format as
> opposed to "number" format. Is there a property statement which will do this?
>
> Thanks

 
Reply With Quote
 
Gijs
Guest
Posts: n/a
 
      6th Aug 2009
On Aug 6, 11:21*am, "Peter T" <peter_t@discussions> wrote:
> Sub Test()
> Dim vGen As Variant
> Dim cel As Range
> Dim rng As Range
>
> * * Set rng = Range("A1:A10")
>
> * * vGen = rng.NumberFormat = "General"
>
> * * If IsNull(vGen) Then
> * * * * MsgBox "at least one cell is General but not all"
> * * * * For Each cel In rng
> * * * * * * Debug.Print cel.Address, cel.NumberFormat
> * * * * Next
> * * ElseIf vGen = True Then
> * * * * MsgBox "all cells are General"
> * * Else
> * * * * MsgBox "no cells are General"
> * * End If
>
> End Sub
>
> Regards,
> Peter T
>
> "PBcorn" <PBc...@discussions.microsoft.com> wrote in message
>
> news:24E2263C-E2FD-49EB-9D22-(E-Mail Removed)...
>
>
>
> >I need a VB expression so I can test for cells with a "general" format as
> > opposed to "number" format. Is there a property statement which will do
> > this?

>
> > Thanks- Hide quoted text -

>
> - Show quoted text -


Hi,
I am able to test on the General format.
My problem is that the value property is always null in case of the
general format.
Value contains the right value for numeric and text format.
Where do I find the cell value in case of 'General'?
Who can help me?
Thanks,
Gijs
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      6th Aug 2009
I don't follow what you are saying, there is no direct connection between
cell's Value and Numberformat properties

When testing a particular format in a multi-cell range, if they are not all
the same the returned value will be Null (which can only be assigned to a
Variant)

What are you trying to do

Regards,
Peter T

"Gijs" <(E-Mail Removed)> wrote in message
news:d522f15d-b161-4a6c-93a4-(E-Mail Removed)...
On Aug 6, 11:21 am, "Peter T" <peter_t@discussions> wrote:

> Hi,
> I am able to test on the General format.
> My problem is that the value property is always null in case of the
> general format.
> Value contains the right value for numeric and text format.
> Where do I find the cell value in case of 'General'?
> Who can help me?
> Thanks,
> Gijs



 
Reply With Quote
 
keiji kounoike
Guest
Posts: n/a
 
      7th Aug 2009
Do you mean you want to find cells that have a General format and that
cells's value is a number or a text to be considered as number?

Keiji

Gijs wrote:
> On Aug 6, 11:21 am, "Peter T" <peter_t@discussions> wrote:
>> Sub Test()
>> Dim vGen As Variant
>> Dim cel As Range
>> Dim rng As Range
>>
>> Set rng = Range("A1:A10")
>>
>> vGen = rng.NumberFormat = "General"
>>
>> If IsNull(vGen) Then
>> MsgBox "at least one cell is General but not all"
>> For Each cel In rng
>> Debug.Print cel.Address, cel.NumberFormat
>> Next
>> ElseIf vGen = True Then
>> MsgBox "all cells are General"
>> Else
>> MsgBox "no cells are General"
>> End If
>>
>> End Sub
>>
>> Regards,
>> Peter T
>>
>> "PBcorn" <PBc...@discussions.microsoft.com> wrote in message
>>
>> news:24E2263C-E2FD-49EB-9D22-(E-Mail Removed)...
>>
>>
>>
>>> I need a VB expression so I can test for cells with a "general" format as
>>> opposed to "number" format. Is there a property statement which will do
>>> this?
>>> Thanks- Hide quoted text -

>> - Show quoted text -

>
> Hi,
> I am able to test on the General format.
> My problem is that the value property is always null in case of the
> general format.
> Value contains the right value for numeric and text format.
> Where do I find the cell value in case of 'General'?
> Who can help me?
> Thanks,
> Gijs

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help please - "General" format for cells. Brit_Raider Microsoft Excel Discussion 5 11th Feb 2007 07:12 PM
"general" cells turned into "accounting" - why and how to reverse =?Utf-8?B?S29saG96?= Microsoft Excel Worksheet Functions 0 17th Jan 2007 05:58 AM
RE: I changed the "general" number format - I want it back =?Utf-8?B?UmF5bWFo?= Microsoft Excel Misc 0 26th Dec 2006 04:33 PM
Format a column wihtout using "Format-Cells-Number-category-etc" =?Utf-8?B?c2VydmU=?= Microsoft Excel Worksheet Functions 4 24th Feb 2006 12:54 AM
Add "Significant Figures" to Number tab in "Format Cells" of Excel =?Utf-8?B?TWU=?= Microsoft Excel Misc 1 14th Oct 2004 12:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:45 PM.