Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sick code needs doctor

here is the code



Sub dater3()
Dim lr As Single
Dim r As Variant
Dim Sr As Long
r = Range("a1").Value

r = Day(r)
MsgBox (r)

Windows("Navy Cash stats April.xls").Activate
Sheets(r).Select

With ActiveSheet

lr = Cells(Rows.Count, 1).End(xlUp).Row

Range("a1", Cells(lr, 1)).Select
For Each cell In Selection
If cell.Value = "7:00" Then
cell.Select
Sr = cell.Row

End If
Next
End With

MsgBox (Sr)

End Sub

the thing is that the last message box comes back zero
there is a cell in that range that says "7:00" its number is 16.
think that the format of X:XX is messin it all up. I can't figure
way around this.


Help Pleas

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default sick code needs doctor

I'm thinking that the 7:00 is being treated as time in
Excel and what you see on the screen is not what it's
storing and using for a value. If you don't want to use
time, try using a different format by putting a quote in
front or changing the : to something else.

If time is OK, then try changing the "If Cell.Value..."
line to read:

If Format(Cell.Value,"H:MM") = "7:00" Then

Dan
-----Original Message-----
here is the code



Sub dater3()
Dim lr As Single
Dim r As Variant
Dim Sr As Long
r = Range("a1").Value

r = Day(r)
MsgBox (r)

Windows("Navy Cash stats April.xls").Activate
Sheets(r).Select

With ActiveSheet

lr = Cells(Rows.Count, 1).End(xlUp).Row

Range("a1", Cells(lr, 1)).Select
For Each cell In Selection
If cell.Value = "7:00" Then
cell.Select
Sr = cell.Row

End If
Next
End With

MsgBox (Sr)

End Sub

the thing is that the last message box comes back zero
there is a cell in that range that says "7:00" its number

is 16. I
think that the format of X:XX is messin it all up. I

can't figure a
way around this.


Help Please


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default sick code needs doctor

you are correct. Time is saved in a cell as the decimal pat of a day So 8AM
is 0.333 , then the "day" value of the date is zero. .

--
Patrick Molloy
Microsoft Excel MVP

"Dan Frederick" wrote in message
...
I'm thinking that the 7:00 is being treated as time in
Excel and what you see on the screen is not what it's
storing and using for a value. If you don't want to use
time, try using a different format by putting a quote in
front or changing the : to something else.

If time is OK, then try changing the "If Cell.Value..."
line to read:

If Format(Cell.Value,"H:MM") = "7:00" Then

Dan
-----Original Message-----
here is the code



Sub dater3()
Dim lr As Single
Dim r As Variant
Dim Sr As Long
r = Range("a1").Value

r = Day(r)
MsgBox (r)

Windows("Navy Cash stats April.xls").Activate
Sheets(r).Select

With ActiveSheet

lr = Cells(Rows.Count, 1).End(xlUp).Row

Range("a1", Cells(lr, 1)).Select
For Each cell In Selection
If cell.Value = "7:00" Then
cell.Select
Sr = cell.Row

End If
Next
End With

MsgBox (Sr)

End Sub

the thing is that the last message box comes back zero
there is a cell in that range that says "7:00" its number

is 16. I
think that the format of X:XX is messin it all up. I

can't figure a
way around this.


Help Please


---
Message posted from http://www.ExcelForum.com/

.



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
Excel Doctor Kassie Links and Linking in Excel 2 August 15th 05 08:25 PM
Excel Doctor Kassie Excel Worksheet Functions 2 August 15th 05 08:25 PM
Excel Doctor GLS Excel Worksheet Functions 2 July 22nd 05 05:09 PM
Excel Doctor GLS Links and Linking in Excel 0 July 22nd 05 08:14 AM
Excel Logic needs a Doctor !! FORMULA FIX DESIRED!! Learning VBA[_3_] Excel Programming 7 November 27th 03 11:10 PM


All times are GMT +1. The time now is 06:44 PM.

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

About Us

"It's about Microsoft Excel"