ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

excel ®É¶¡¬O§_¥i¥H¬Û´î

excel ®É¶¡¬O§_¥i¥H¬Û´î

·Q½Ð°Ý¤@¤U®É¶¡¬O§_¥i¥H¬Û´î
¸ó¤p®É©M¸ó¤Ñ, ¬Û´î¤U¨Ó·|¦³°ÝÃD,
·Q½Ð°Ý¤@¤U, ­n¦p¦ó­×§ï
  1. Sub TimeCal(ByVal RowNo)
  2.     Dim T1_H%
  3.     Dim T1_M%
  4.     Dim T2_H%
  5.     Dim T2_M%
  6.     Dim Diff_All!
  7.     Dim Diff_H%
  8.     Dim Diff_M!
  9.     Dim Str_T1 As Object
  10.     Dim Str_T2 As Object
  11.    
  12.     Set Str_T1 = Sheets("list").Range("G" & RowNo)    ' Str_T1 = 2015/3/9  06:49:59
  13.     Set Str_T2 = Sheets("list").Range("H" & RowNo)    ' Str_T2 = 2015/3/1  05:41:39
  14.    
  15.     T1_H = Hour(Str_T1)
  16.     T1_M = Minute(Str_T1)
  17.     T2_H = Hour(Str_T2)
  18.     T2_M = Minute(Str_T2)

  19.     Diff_H = Abs(T1_H - T2_H)
  20.     Diff_M = Abs(T1_M - T2_M) / 60
  21.     Diff_All = Diff_H + Diff_M
  22.    
  23.     Sheets("list").Range("K" & RowNo).Value = Diff_All

  24. End Sub
½Æ»s¥N½X

ÁÂÁ«ü¾É, ¤§«e¤]¬O³o¼Ëª½±µ¬Û´î, ¦ý´î«á³£¬O 0.01xxx
¦ý§Ú¬Ý¤W­±¦³¦b X 24 , ³o­Ó·N«ä¤£¬O«ÜÀ´, ¥i¥H»¡©ú¤@¤U¶Ü
¬°¤°»ò¤£¬O X 60 ???
¤£¹L¥H³o­Óºâªk¨Ó, ¬Ý°_¬Ook

TOP

¥i¥H¦A¦h°Ý¤@­Ó°ÝÃD¶Ü

QueryTables ­n¦p¦ó滙¤J¨ä¥Lªº excel ÀÉ®×
³o¬O¿ý¸m¥¨¶°©Ò²£¥Íªºµ{¦¡½X, ¦ý¤£¤F¸Ñ³o­Ó»yªk, ¥i¥H¸Ñµª¶Ü
  ³o­Ó¥¨¶°¥i¥H¦A²¤Æ¶Ü  

  With ActiveSheet.QueryTables.Add(Connection:=Array( _
        "OLEDBrovider=Microsoft.Jet.OLEDB.4.0assword="""";User ID=Admin;Data Source=I:\VBA.xls;Mode=Share Deny Write;Extended Prop" _
        , _
        "erties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase Password="""";Jet OLEDB:Engine Type=3" _
        , _
        "5;Jet OLEDBatabase Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Datab" _
        , _
        "ase Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDBon't Copy Locale on Compact=F" _
        , "alse;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"), _
        Destination:=Range("A2"))
        .CommandType = xlCmdTable
        .CommandText = Array("Status$")
        .Name = "VBA_1"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .SourceDataFile = "I:\VBA.xls"
        .Refresh BackgroundQuery:=False
    End With

TOP

·PÁ¤j¤jªº»¡©ú

TOP

  1. Sub ex()
  2.     Dim a, b, c

  3.     For c = 1 To 20
  4.         a = Range("A" & c + 1).Value
  5.         b = Range("B" & c + 1).Value
  6.         If a = "" Then Exit For
  7.         If b < a Then b = b + 1
  8.         With Cells(c + 1, 3)
  9.             .Value = (b - a) * 24
  10.             .NumberFormat = "0.00®É"
  11.         End With
  12.     Next
  13. End Sub
½Æ»s¥N½X
¦^´_ 8# xmi

TOP

¤£À´, ¤@¤Ñ¤]¤~ 24 ¤p®É, ¬°¤°»ò·|¥X²{ 27:00 and 25:45 ?

TOP

xmi : ³o­Óµ²ªG¥X¿ù¤F, ³Ì§À¨â­Óªºµ²ªGÀ³¬O2.45¤p®É, ©M2.12¤p¤~¹ï.  ½Ð°Ý¿ù¦b¨º¸Ì?
ANS
®É¶¡¤£¬O¤Q¶i¦ì¼Æ,
¤@¤Ñ¬O 24 ¤p®É
¤@¤p®É¬O 60 ¤À  (60¶i¦ì¼Æ)
¤@¤ÀÄÁ¬O 60 ¬í  (60¶i¦ì¼Æ)
¦]¬°§A­nºâªº¬O¤p®É, ©Ò¥H¤À¥À¤£¥i¥H¥Î10 ¦Ó¬O­n¥Î 60 ¨Ó¬Ý
©Ò¥H GBKEEª©¥D¤~·|¥Î³o­Óºâ¦¡µ¹§A¬Ý    ( ¤À=>¤p®É)
45/60->=0.75
12/60->=0.2
¦ý¦pªG§Aµw­n¼g¦¨ 2.45¤p®É, ©M2.12
¨º§A¥i¯à­n§ï¤@¤U§Aªº¼gªk 2:45 ©M 2:12, ³o¼Ë§O¤H¤ñ¸û¬ÝªºÀ´

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD