Dim cell As Range
For Each cell In Selection.Columns(1).Cells
With cell
if isnumeric(.Value) then
.Value = ((.Value \ 100) + (.Value - _
(.Value \ 100) * 100) / 60) / 24
.NumberFormat = "h:mm AM/PM"
End if
End With
Next cell
/ this is normal division
\ this is integer division
demo'd from the immediate window:
? 7 / 3
2.33333333333333
? 7 \ 3
2
--
Regards,
Tom Ogilvy
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bob et al,
>
> A couple more questions to help my ignorance:
>
> 1.) In the spreadsheet I have columns which include one of two
> possible text strings: BKD or ANR. I need to leave them without
> changing them. The macro you have helped me with gets stuck when it
> encounters text. How do I get the macro to differentiate between text
> and integers? And how do I get it to ignore the text?
>
> 2.) what is the difference between using the '\' and '/' in this line:
> .Value = ((.Value \ 100) + (.Value - (.Value \ 100) * 100) / 60)
>> > / 24
>
> Cheers and thanks again.
>
> James
>
> (E-Mail Removed) wrote:
>> Thanks Bob - now I understand the offset. Brilliant - thank you again.
>>
>> James
>>
>> Bob Phillips wrote:
>> > Dim cell As Range
>> >
>> > For Each cell In Selection.Columns(1).Cells
>> > With cell
>> > .Value = ((.Value \ 100) + (.Value - (.Value \ 100) * 100)
>> > / 60)
>> > / 24
>> > .NumberFormat = "h:mm AM/PM"
>> > End With
>> > Next cell
>> >
>> >
>> >
>> > --
>> > ---
>> > HTH
>> >
>> > Bob
>> >
>> > (change the xxxx to gmail if mailing direct)
>> >
>> >
>> > <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> > > Thanks Bob for the macro. It has been interesting working through
>> > > what you have done with it as this is the first time I am working
>> > > with
>> > > VBA.
>> > >
>> > > Is it possible to get the macro to replace the existing values
>> > > instead
>> > > of starting a new column?
>> > >
>> > > Cheers - James
>> > >
>> > > PS Richard thanks also for the simpler formula (I've just woken up -
>> > > West coast of Australia). I'm about to work through what you have
>> > > done
>> > > with that as it does seem a lot simpler than what I was using.
>> > >
>