PC Review


Reply
Thread Tools Rate Thread

Adding Leading Zeros; Formatting as Time

 
 
D. Stacy
Guest
Posts: n/a
 
      4th May 2009
I have columns of text data representing military time (i.e. 1500, 900, 730,
45). The below code shell is designed to determine how many digits are
present and then perform come "action". I need to write the code for the
"action", now that the rest of this is working.

The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM

In excel, using formulas, this is accomplished using a mega formula
consisting of a lot of if statements, etc. etc. And it invloves inserting
columns in the native data to accept the reformed data. My goal is to simply
select the columns that need to be reformed and then run the code.




Sub ConfigureTimeData()
' Converts text time data to 4 digit time data
Dim ConstantCells As Range
Dim Cell As Range
Dim Length As Double

If TypeName(Selection) <> "Range" Then Exit Sub
Application.ScreenUpdating = False

' Create subsets of original selection to avoid processing empty cells
On Error Resume Next
Set ConstantCells = Selection.SpecialCells(xlConstants)

On Error GoTo 0



' Process the constant cells
If Not ConstantCells Is Nothing Then
For Each Cell In ConstantCells
Select Case Len(Cell.Text)

Case 0
Cell.Interior.Pattern = xlNone
Cell.Value = " "
Case 1
Cell.Interior.Pattern = xlNone

Case 2
Cell.Interior.Pattern = xlNone
Cell.Value = "Two"
Case 3
Cell.Interior.Pattern = xlNone
Cell.Value = "Three"
Case 4
Cell.Interior.Pattern = xlNone
Cell.Value = "Four"
Case Is > 4
Cell.Interior.Color = RGB(255, 0, 255)
Cell.Value = "ERROR"
End Select



Next Cell
End If



End Sub


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th May 2009
You could use a formula like:
=--TEXT(A1,"00\:00")
and then format the cell with a time format:
h:mm AM/PM

And the value will be a real time (nice for further calculations)

Or you could use:
=TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
to return text

In code, you could do something like this to return a real time:

Option Explicit
Sub testme()
Dim myStr As String
Dim myRng As Range
Dim myCell As Range

Set myRng = Selection
For Each myCell In myRng.Cells
With myCell
.NumberFormat = "h:mm AM/PM"
.Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100, 0)
End With
Next myCell

End Sub

Or this to return text:
Option Explicit
Sub testme()
Dim myStr As String
Dim myRng As Range
Dim myCell As Range

Set myRng = Selection
For Each myCell In myRng.Cells
With myCell
.NumberFormat = "@" 'text
.Value = Format(TimeSerial(myCell.Value \ 100, _
myCell.Value Mod 100, 0), "h:mm AM/PM")
End With
Next myCell

End Sub





D. Stacy wrote:
>
> I have columns of text data representing military time (i.e. 1500, 900, 730,
> 45). The below code shell is designed to determine how many digits are
> present and then perform come "action". I need to write the code for the
> "action", now that the rest of this is working.
>
> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM
>
> In excel, using formulas, this is accomplished using a mega formula
> consisting of a lot of if statements, etc. etc. And it invloves inserting
> columns in the native data to accept the reformed data. My goal is to simply
> select the columns that need to be reformed and then run the code.
>
> Sub ConfigureTimeData()
> ' Converts text time data to 4 digit time data
> Dim ConstantCells As Range
> Dim Cell As Range
> Dim Length As Double
>
> If TypeName(Selection) <> "Range" Then Exit Sub
> Application.ScreenUpdating = False
>
> ' Create subsets of original selection to avoid processing empty cells
> On Error Resume Next
> Set ConstantCells = Selection.SpecialCells(xlConstants)
>
> On Error GoTo 0
>
>
> ' Process the constant cells
> If Not ConstantCells Is Nothing Then
> For Each Cell In ConstantCells
> Select Case Len(Cell.Text)
>
> Case 0
> Cell.Interior.Pattern = xlNone
> Cell.Value = " "
> Case 1
> Cell.Interior.Pattern = xlNone
>
> Case 2
> Cell.Interior.Pattern = xlNone
> Cell.Value = "Two"
> Case 3
> Cell.Interior.Pattern = xlNone
> Cell.Value = "Three"
> Case 4
> Cell.Interior.Pattern = xlNone
> Cell.Value = "Four"
> Case Is > 4
> Cell.Interior.Color = RGB(255, 0, 255)
> Cell.Value = "ERROR"
> End Select
>
>
>
> Next Cell
> End If
>
>
>
> End Sub


--

Dave Peterson
 
Reply With Quote
 
AltaEgo
Guest
Posts: n/a
 
      4th May 2009
Dave

I like the formatting solution. Do you any references where I can learn a
little more?

--
Steve

"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You could use a formula like:
> =--TEXT(A1,"00\:00")
> and then format the cell with a time format:
> h:mm AM/PM
>
> And the value will be a real time (nice for further calculations)
>
> Or you could use:
> =TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
> to return text
>
> In code, you could do something like this to return a real time:
>
> Option Explicit
> Sub testme()
> Dim myStr As String
> Dim myRng As Range
> Dim myCell As Range
>
> Set myRng = Selection
> For Each myCell In myRng.Cells
> With myCell
> .NumberFormat = "h:mm AM/PM"
> .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100,
> 0)
> End With
> Next myCell
>
> End Sub
>
> Or this to return text:
> Option Explicit
> Sub testme()
> Dim myStr As String
> Dim myRng As Range
> Dim myCell As Range
>
> Set myRng = Selection
> For Each myCell In myRng.Cells
> With myCell
> .NumberFormat = "@" 'text
> .Value = Format(TimeSerial(myCell.Value \ 100, _
> myCell.Value Mod 100, 0), "h:mm AM/PM")
> End With
> Next myCell
>
> End Sub
>
>
>
>
>
> D. Stacy wrote:
>>
>> I have columns of text data representing military time (i.e. 1500, 900,
>> 730,
>> 45). The below code shell is designed to determine how many digits are
>> present and then perform come "action". I need to write the code for the
>> "action", now that the rest of this is working.
>>
>> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM
>>
>> In excel, using formulas, this is accomplished using a mega formula
>> consisting of a lot of if statements, etc. etc. And it invloves inserting
>> columns in the native data to accept the reformed data. My goal is to
>> simply
>> select the columns that need to be reformed and then run the code.
>>
>> Sub ConfigureTimeData()
>> ' Converts text time data to 4 digit time data
>> Dim ConstantCells As Range
>> Dim Cell As Range
>> Dim Length As Double
>>
>> If TypeName(Selection) <> "Range" Then Exit Sub
>> Application.ScreenUpdating = False
>>
>> ' Create subsets of original selection to avoid processing empty cells
>> On Error Resume Next
>> Set ConstantCells = Selection.SpecialCells(xlConstants)
>>
>> On Error GoTo 0
>>
>>
>> ' Process the constant cells
>> If Not ConstantCells Is Nothing Then
>> For Each Cell In ConstantCells
>> Select Case Len(Cell.Text)
>>
>> Case 0
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = " "
>> Case 1
>> Cell.Interior.Pattern = xlNone
>>
>> Case 2
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Two"
>> Case 3
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Three"
>> Case 4
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Four"
>> Case Is > 4
>> Cell.Interior.Color = RGB(255, 0, 255)
>> Cell.Value = "ERROR"
>> End Select
>>
>>
>>
>> Next Cell
>> End If
>>
>>
>>
>> End Sub

>
> --
>
> Dave Peterson


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      4th May 2009
You should be able to replace this statement from your VBA code...

..Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100, 0)

with this simpler statement...

..Value = CDate(Format(myCell.Value, "00:00"))

--
Rick (MVP - Excel)


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You could use a formula like:
> =--TEXT(A1,"00\:00")
> and then format the cell with a time format:
> h:mm AM/PM
>
> And the value will be a real time (nice for further calculations)
>
> Or you could use:
> =TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
> to return text
>
> In code, you could do something like this to return a real time:
>
> Option Explicit
> Sub testme()
> Dim myStr As String
> Dim myRng As Range
> Dim myCell As Range
>
> Set myRng = Selection
> For Each myCell In myRng.Cells
> With myCell
> .NumberFormat = "h:mm AM/PM"
> .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100,
> 0)
> End With
> Next myCell
>
> End Sub
>
> Or this to return text:
> Option Explicit
> Sub testme()
> Dim myStr As String
> Dim myRng As Range
> Dim myCell As Range
>
> Set myRng = Selection
> For Each myCell In myRng.Cells
> With myCell
> .NumberFormat = "@" 'text
> .Value = Format(TimeSerial(myCell.Value \ 100, _
> myCell.Value Mod 100, 0), "h:mm AM/PM")
> End With
> Next myCell
>
> End Sub
>
>
>
>
>
> D. Stacy wrote:
>>
>> I have columns of text data representing military time (i.e. 1500, 900,
>> 730,
>> 45). The below code shell is designed to determine how many digits are
>> present and then perform come "action". I need to write the code for the
>> "action", now that the rest of this is working.
>>
>> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM
>>
>> In excel, using formulas, this is accomplished using a mega formula
>> consisting of a lot of if statements, etc. etc. And it invloves inserting
>> columns in the native data to accept the reformed data. My goal is to
>> simply
>> select the columns that need to be reformed and then run the code.
>>
>> Sub ConfigureTimeData()
>> ' Converts text time data to 4 digit time data
>> Dim ConstantCells As Range
>> Dim Cell As Range
>> Dim Length As Double
>>
>> If TypeName(Selection) <> "Range" Then Exit Sub
>> Application.ScreenUpdating = False
>>
>> ' Create subsets of original selection to avoid processing empty cells
>> On Error Resume Next
>> Set ConstantCells = Selection.SpecialCells(xlConstants)
>>
>> On Error GoTo 0
>>
>>
>> ' Process the constant cells
>> If Not ConstantCells Is Nothing Then
>> For Each Cell In ConstantCells
>> Select Case Len(Cell.Text)
>>
>> Case 0
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = " "
>> Case 1
>> Cell.Interior.Pattern = xlNone
>>
>> Case 2
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Two"
>> Case 3
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Three"
>> Case 4
>> Cell.Interior.Pattern = xlNone
>> Cell.Value = "Four"
>> Case Is > 4
>> Cell.Interior.Color = RGB(255, 0, 255)
>> Cell.Value = "ERROR"
>> End Select
>>
>>
>>
>> Next Cell
>> End If
>>
>>
>>
>> End Sub

>
> --
>
> Dave Peterson


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th May 2009
For the =text() worksheet function, check excel's help.

For VBA's Format, check VBA's help.



AltaEgo wrote:
>
> Dave
>
> I like the formatting solution. Do you any references where I can learn a
> little more?
>
> --
> Steve
>
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > You could use a formula like:
> > =--TEXT(A1,"00\:00")
> > and then format the cell with a time format:
> > h:mm AM/PM
> >
> > And the value will be a real time (nice for further calculations)
> >
> > Or you could use:
> > =TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
> > to return text
> >
> > In code, you could do something like this to return a real time:
> >
> > Option Explicit
> > Sub testme()
> > Dim myStr As String
> > Dim myRng As Range
> > Dim myCell As Range
> >
> > Set myRng = Selection
> > For Each myCell In myRng.Cells
> > With myCell
> > .NumberFormat = "h:mm AM/PM"
> > .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100,
> > 0)
> > End With
> > Next myCell
> >
> > End Sub
> >
> > Or this to return text:
> > Option Explicit
> > Sub testme()
> > Dim myStr As String
> > Dim myRng As Range
> > Dim myCell As Range
> >
> > Set myRng = Selection
> > For Each myCell In myRng.Cells
> > With myCell
> > .NumberFormat = "@" 'text
> > .Value = Format(TimeSerial(myCell.Value \ 100, _
> > myCell.Value Mod 100, 0), "h:mm AM/PM")
> > End With
> > Next myCell
> >
> > End Sub
> >
> >
> >
> >
> >
> > D. Stacy wrote:
> >>
> >> I have columns of text data representing military time (i.e. 1500, 900,
> >> 730,
> >> 45). The below code shell is designed to determine how many digits are
> >> present and then perform come "action". I need to write the code for the
> >> "action", now that the rest of this is working.
> >>
> >> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM
> >>
> >> In excel, using formulas, this is accomplished using a mega formula
> >> consisting of a lot of if statements, etc. etc. And it invloves inserting
> >> columns in the native data to accept the reformed data. My goal is to
> >> simply
> >> select the columns that need to be reformed and then run the code.
> >>
> >> Sub ConfigureTimeData()
> >> ' Converts text time data to 4 digit time data
> >> Dim ConstantCells As Range
> >> Dim Cell As Range
> >> Dim Length As Double
> >>
> >> If TypeName(Selection) <> "Range" Then Exit Sub
> >> Application.ScreenUpdating = False
> >>
> >> ' Create subsets of original selection to avoid processing empty cells
> >> On Error Resume Next
> >> Set ConstantCells = Selection.SpecialCells(xlConstants)
> >>
> >> On Error GoTo 0
> >>
> >>
> >> ' Process the constant cells
> >> If Not ConstantCells Is Nothing Then
> >> For Each Cell In ConstantCells
> >> Select Case Len(Cell.Text)
> >>
> >> Case 0
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = " "
> >> Case 1
> >> Cell.Interior.Pattern = xlNone
> >>
> >> Case 2
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Two"
> >> Case 3
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Three"
> >> Case 4
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Four"
> >> Case Is > 4
> >> Cell.Interior.Color = RGB(255, 0, 255)
> >> Cell.Value = "ERROR"
> >> End Select
> >>
> >>
> >>
> >> Next Cell
> >> End If
> >>
> >>
> >>
> >> End Sub

> >
> > --
> >
> > Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th May 2009
Or even replace this:
.Value = TimeSerial(.Value \ 100, .Value Mod 100, 0)
with
.Value = CDate(Format(.Value, "00:00"))
or even
.Value = Format(.Value, "00:00")

(too many myCell's left in the original code.)

But it bothers me (a personal bother) that 00:00 is treated as hh:mm, not
mm:ss. And I don't trust my memory (or excel) to not use something like:

.Value = Format(.Value, "00:00") & ":00"

=======
Please don't ask why I trusted =text() though!

Inconsistencies are good for the soul <vbg>.

Rick Rothstein wrote:
>
> You should be able to replace this statement from your VBA code...
>
> .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100, 0)
>
> with this simpler statement...
>
> .Value = CDate(Format(myCell.Value, "00:00"))
>
> --
> Rick (MVP - Excel)
>
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > You could use a formula like:
> > =--TEXT(A1,"00\:00")
> > and then format the cell with a time format:
> > h:mm AM/PM
> >
> > And the value will be a real time (nice for further calculations)
> >
> > Or you could use:
> > =TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
> > to return text
> >
> > In code, you could do something like this to return a real time:
> >
> > Option Explicit
> > Sub testme()
> > Dim myStr As String
> > Dim myRng As Range
> > Dim myCell As Range
> >
> > Set myRng = Selection
> > For Each myCell In myRng.Cells
> > With myCell
> > .NumberFormat = "h:mm AM/PM"
> > .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod 100,
> > 0)
> > End With
> > Next myCell
> >
> > End Sub
> >
> > Or this to return text:
> > Option Explicit
> > Sub testme()
> > Dim myStr As String
> > Dim myRng As Range
> > Dim myCell As Range
> >
> > Set myRng = Selection
> > For Each myCell In myRng.Cells
> > With myCell
> > .NumberFormat = "@" 'text
> > .Value = Format(TimeSerial(myCell.Value \ 100, _
> > myCell.Value Mod 100, 0), "h:mm AM/PM")
> > End With
> > Next myCell
> >
> > End Sub
> >
> >
> >
> >
> >
> > D. Stacy wrote:
> >>
> >> I have columns of text data representing military time (i.e. 1500, 900,
> >> 730,
> >> 45). The below code shell is designed to determine how many digits are
> >> present and then perform come "action". I need to write the code for the
> >> "action", now that the rest of this is working.
> >>
> >> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45 AM
> >>
> >> In excel, using formulas, this is accomplished using a mega formula
> >> consisting of a lot of if statements, etc. etc. And it invloves inserting
> >> columns in the native data to accept the reformed data. My goal is to
> >> simply
> >> select the columns that need to be reformed and then run the code.
> >>
> >> Sub ConfigureTimeData()
> >> ' Converts text time data to 4 digit time data
> >> Dim ConstantCells As Range
> >> Dim Cell As Range
> >> Dim Length As Double
> >>
> >> If TypeName(Selection) <> "Range" Then Exit Sub
> >> Application.ScreenUpdating = False
> >>
> >> ' Create subsets of original selection to avoid processing empty cells
> >> On Error Resume Next
> >> Set ConstantCells = Selection.SpecialCells(xlConstants)
> >>
> >> On Error GoTo 0
> >>
> >>
> >> ' Process the constant cells
> >> If Not ConstantCells Is Nothing Then
> >> For Each Cell In ConstantCells
> >> Select Case Len(Cell.Text)
> >>
> >> Case 0
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = " "
> >> Case 1
> >> Cell.Interior.Pattern = xlNone
> >>
> >> Case 2
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Two"
> >> Case 3
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Three"
> >> Case 4
> >> Cell.Interior.Pattern = xlNone
> >> Cell.Value = "Four"
> >> Case Is > 4
> >> Cell.Interior.Color = RGB(255, 0, 255)
> >> Cell.Value = "ERROR"
> >> End Select
> >>
> >>
> >>
> >> Next Cell
> >> End If
> >>
> >>
> >>
> >> End Sub

> >
> > --
> >
> > Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
AltaEgo
Guest
Posts: n/a
 
      4th May 2009
Dave,

actually, I had in mind a few samples or different applications for
formatting using TEXT to open up a mind that was locked into the Access
Format function solely used for time and date. Having given it more thought
time yesterday, I generated enough ideas to to understand potential
alternate application of TEXT - nothing focuses the mind like a sixty minute
run!

--
Steve

"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> For the =text() worksheet function, check excel's help.
>
> For VBA's Format, check VBA's help.
>
>
>
> AltaEgo wrote:
>>
>> Dave
>>
>> I like the formatting solution. Do you any references where I can learn a
>> little more?
>>
>> --
>> Steve
>>
>> "Dave Peterson" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > You could use a formula like:
>> > =--TEXT(A1,"00\:00")
>> > and then format the cell with a time format:
>> > h:mm AM/PM
>> >
>> > And the value will be a real time (nice for further calculations)
>> >
>> > Or you could use:
>> > =TEXT(TEXT(A1,"00\:00"),"h:mm AM/PM"
>> > to return text
>> >
>> > In code, you could do something like this to return a real time:
>> >
>> > Option Explicit
>> > Sub testme()
>> > Dim myStr As String
>> > Dim myRng As Range
>> > Dim myCell As Range
>> >
>> > Set myRng = Selection
>> > For Each myCell In myRng.Cells
>> > With myCell
>> > .NumberFormat = "h:mm AM/PM"
>> > .Value = TimeSerial(myCell.Value \ 100, myCell.Value Mod
>> > 100,
>> > 0)
>> > End With
>> > Next myCell
>> >
>> > End Sub
>> >
>> > Or this to return text:
>> > Option Explicit
>> > Sub testme()
>> > Dim myStr As String
>> > Dim myRng As Range
>> > Dim myCell As Range
>> >
>> > Set myRng = Selection
>> > For Each myCell In myRng.Cells
>> > With myCell
>> > .NumberFormat = "@" 'text
>> > .Value = Format(TimeSerial(myCell.Value \ 100, _
>> > myCell.Value Mod 100, 0), "h:mm AM/PM")
>> > End With
>> > Next myCell
>> >
>> > End Sub
>> >
>> >
>> >
>> >
>> >
>> > D. Stacy wrote:
>> >>
>> >> I have columns of text data representing military time (i.e. 1500,
>> >> 900,
>> >> 730,
>> >> 45). The below code shell is designed to determine how many digits
>> >> are
>> >> present and then perform come "action". I need to write the code for
>> >> the
>> >> "action", now that the rest of this is working.
>> >>
>> >> The desired output would look like : 3:00 PM, 9:00 AM, 7:30 AM, 12:45
>> >> AM
>> >>
>> >> In excel, using formulas, this is accomplished using a mega formula
>> >> consisting of a lot of if statements, etc. etc. And it invloves
>> >> inserting
>> >> columns in the native data to accept the reformed data. My goal is to
>> >> simply
>> >> select the columns that need to be reformed and then run the code.
>> >>
>> >> Sub ConfigureTimeData()
>> >> ' Converts text time data to 4 digit time data
>> >> Dim ConstantCells As Range
>> >> Dim Cell As Range
>> >> Dim Length As Double
>> >>
>> >> If TypeName(Selection) <> "Range" Then Exit Sub
>> >> Application.ScreenUpdating = False
>> >>
>> >> ' Create subsets of original selection to avoid processing empty
>> >> cells
>> >> On Error Resume Next
>> >> Set ConstantCells = Selection.SpecialCells(xlConstants)
>> >>
>> >> On Error GoTo 0
>> >>
>> >>
>> >> ' Process the constant cells
>> >> If Not ConstantCells Is Nothing Then
>> >> For Each Cell In ConstantCells
>> >> Select Case Len(Cell.Text)
>> >>
>> >> Case 0
>> >> Cell.Interior.Pattern = xlNone
>> >> Cell.Value = " "
>> >> Case 1
>> >> Cell.Interior.Pattern = xlNone
>> >>
>> >> Case 2
>> >> Cell.Interior.Pattern = xlNone
>> >> Cell.Value = "Two"
>> >> Case 3
>> >> Cell.Interior.Pattern = xlNone
>> >> Cell.Value = "Three"
>> >> Case 4
>> >> Cell.Interior.Pattern = xlNone
>> >> Cell.Value = "Four"
>> >> Case Is > 4
>> >> Cell.Interior.Color = RGB(255, 0, 255)
>> >> Cell.Value = "ERROR"
>> >> End Select
>> >>
>> >>
>> >>
>> >> Next Cell
>> >> End If
>> >>
>> >>
>> >>
>> >> End Sub
>> >
>> > --
>> >
>> > Dave Peterson

>
> --
>
> Dave Peterson


 
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
Re: Adding Leading Zeros; Formatting as Time AltaEgo Microsoft Excel Programming 0 4th May 2009 02:26 AM
Adding leading zeros =?Utf-8?B?U0lUQ0ZhblRO?= Microsoft Excel Programming 3 10th Jul 2007 07:12 PM
adding leading zeros =?Utf-8?B?Q2hyaXM=?= Microsoft Access Queries 3 19th Apr 2005 06:23 PM
formatting numbers with leading zeros cody Microsoft Dot NET 3 14th Oct 2004 08:59 AM
Adding Leading zeros Nat Microsoft Access 2 16th Dec 2003 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 AM.