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

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

¥»©«³Ì«á¥Ñ 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

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

TOP

¦^´_ 2# ML089

¯u¦hÁÂML089¦Ñ®vªº¦^µª¡A¦pªG¿é¤J¤é´Á.®É¶¡«á¡A§Ú¦b¤â°Ê§ó§ï°_©l®É¶¡©Îµ²§ô®É¶¡¡A¥i§_Åý²Î­pªº"¤À"¡A¤]¦P®É¦P¨BÅܧó¥[Á`¡A³Â·Ð¦Ñ®v¤F^^

TOP

  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. Dim r%, xD As Range, xE As Range, xF As Range
  3. With Target
  4.       If .Count > 1 Then Exit Sub
  5.       If Intersect(Union([B:B], [C:C]), .Cells) Is Nothing Then Exit Sub
  6.       Application.EnableEvents = False
  7.       .Offset(0, 2).Value = Now()
  8.       r = .Row() - 1: Set xD = [D1].Offset(r, 0): Set xE = [E1].Offset(r, 0): Set xF = [F1].Offset(r, 0)
  9.       If Application.Count(xD, xE) = 2 Then xF = Int((xE - xD) * 24 * 60)
  10.       Application.EnableEvents = True
  11. End With
  12. End Sub
½Æ»s¥N½X
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD