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

¦p¦ó§Q¥ÎVBAIJµoÀx¦s®æ²£¥Í¤é´Á.®É¶¡

¦^´_ 2# ML089
·PÁ ML089¶Wª©ªºVBAªº

TOP

¥»©«³Ì«á¥Ñ yen956 ©ó 2016-1-8 15:55 ½s¿è

¸Õ¸Õ¬Ý!!
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     Dim Lst As Integer, r As Integer
  3.     Lst = [A65536].End(xlUp).Row
  4.     If Target.Count > 2 Then Exit Sub  '¦pªG¤@¦¸§ïÅܦh®æ«h¨S§@¥Î
  5.     r = Target.Row
  6.     If r > Lst Then Exit Sub  '¦pªG³Ì¤U­±ªº³¡ªù¬°ªÅ¥Õ«h¨S§@¥Î
  7.    
  8.     '¦pªG§ïÅܪºÀx¦s®æ¤£¦b BÄæ ©Î CÄæ «h¨S§@¥Î
  9.     If Target.Column <> 2 And Target.Column <> 3 Then Exit Sub
  10.    
  11.     '¦pªG Target ¬°ªÅ¥Õ, «h¹j¨âÄæ¤Ï¥Õ, ¨Ã²M°£[Fxx]
  12.     If Target = "" Then
  13.         Target.Offset(0, 2) = ""
  14.         Target.Offset(0, 2).Interior.ColorIndex = 35
  15.         Cells(r, 6) = ""
  16.     Else
  17.         Target.Offset(0, 2) = Now    '§_«h¹j¨âÄæ¨ú®ø¤Ï¥Õ, ¶ñ¤J²{¦b®É¶¡
  18.         Target.Offset(0, 2).Interior.ColorIndex = xlNone
  19.     End If
  20.         
  21.     '¦pªG [Dxx] ¤Î [Exx] ¤£¬OªÅ¥Õ, ¦b [Fxx] ­pºâ®É®t(¥H¤ÀÄÁ¬°³æ¦ì)
  22.     If Cells(r, 4) <> "" And Cells(r, 5) <> "" Then
  23.         Cells(r, 6) = Int((Cells(r, 5) - Cells(r, 4)) * 24 * 60)
  24.     End If
  25. End Sub
½Æ»s¥N½X
test.gif

TOP

¦^´_ 6# ML089
ÁÂÁ¤j¤jªº«ü¾É!!
¤×¨ä¬O¥Î
Range("F" & .Row) = "=IF(COUNT(RC4:RC5)=2,INT((RC5-RC4)*24*60),"""")"
ªº¨Ï¥Î, ¥i¥H²¤Æ¤£¤Ö If A and B then ... ªº¼gªk, «D±`¹ê¥Î, ¦¬¤U, ÁÂÁÂ

TOP

¦^´_ 7# man65boy
"¦ý¦pªG¤â°Ê§ó§ï®É¶¡ªº¸Ü¡A¦@­p"¤À"¥i§_¦P®É§ó§ï¼Æ¾Ú"
¬Ý¤£À´§Aªº»Ý¨D¬O¤°»ò?

TOP

¦^´_ 12# man65boy
¸Õ¸Õ¬Ý:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Lst As Integer, r As Integer, Rng As Range
    Lst = [A65536].End(xlUp).Row    '¨ú±o ÄæA ³Ì¤U­±«DªÅ¥Õ®æªº¦C¸¹
    Set Rng = [B2].Resize(Lst - 1, 4)   '³]©wWorksheet_ChangeIJ°Ê½d³ò¬°[B2:Dxx], xx=Lst(¦C¸¹)
    If Target.Count > 2 Then Exit Sub   '¦pªG¤@¦¸§ïÅܦh®æ«h¨S§@¥Î
    If Intersect(Target, Rng) Is Nothing Then Exit Sub   '¦pªG§ïÅܪºÀx¦s®æ¤£¦b¹w­p½d³ò¤º«h¨S§@¥Î
    r = Target.Row
    '¦pªG§ïÅܪºÀx¦s®æ¬O BÄæ ©Î CÄæ, «h
    If Target.Column = 2 Or Target.Column = 3 Then
        '¡¹¦pªG Target ¬°ªÅ¥Õ, «h
        If Target = "" Then
            Target.Offset(0, 2) = ""                      '²M°£¦P¦C¥kÃä¨âÄ檺Cell
            Target.Offset(0, 2).Interior.ColorIndex = 35  '¨Ã¤Ï¥Õ
            Target.Cells(r, 6) = ""              '¨Ã²M°£¦P¦Cªº[Fxx]
        '¡¹§_«h
        Else
            '¦pªG¦P¦C¥kÃä¨âÄ檺Cell¬°ªÅ¥Õ, «h¶ñ¤J²{¦b®É¶¡, ¤£¬OªÅ¥Õ, «h¤£¶ñ
            If Target.Offset(0, 2) = "" Then
                Target.Offset(0, 2) = Now                         '¶ñ¤J²{¦b®É¶¡
                Target.Offset(0, 2).Interior.ColorIndex = xlNone  '¥B¨ú®ø¤Ï¥Õ
            End If
        End If
    End If
        
    '¦pªG °_©l®É¶¡ ¤Î µ²§ô®É¶¡ ¤£¬OªÅ¥Õ, «h¦b [Fxx] ­pºâ®É®t(¥H¤ÀÄÁ¬°³æ¦ì)
    If Application.Count(Cells(r, 4), Cells(r, 5)) = 2 Then
        Cells(r, 6) = Int((Cells(r, 5) - Cells(r, 4)) * 24 * 60)
    End If
End Sub

TOP

        ÀR«ä¦Û¦b : ¡i°µ¤Hªº¶}©l¡j¨C¤@¤Ñ³£¬O¬G¤Hªº¶}©l¡A¨C¤@­Ó®É¨è³£¬O¦Û¤vªºÄµ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD