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

§Q¥ÎVBA±N·j´M¤º®eÅã¥Ü¥X¨Ó(¼Æµ§¸ê®Æ)

¥»©«³Ì«á¥Ñ yen956 ©ó 2017-4-17 14:36 ½s¿è

¦^´_ 2# bioleon69
¸Õ¸Õ¬Ý:
  1. '·j´M
  2. Private Sub CommandButton1_Click()
  3.     Dim eR As Long, Dt As Date, Dt1 As Date, Dt2 As Date, St As String, Rng As Range, E
  4.     If [E2] = "" And [E4] = "" Then Exit Sub
  5.     [G2].Resize(Rows.Count - 1, 3) = ""
  6.     eR = [A65536].End(xlUp).Row
  7.     Set Rng = [A2].Resize(eR - 1, 1)
  8.     If [E2] <> "" Then
  9.         Dt1 = [E2] & "/1"
  10.         Dt2 = Year(Dt1) & "/" & Month(Dt1) + 1 & "/1"
  11.      End If
  12.     For Each E In Rng
  13.         Dt = E: St = E.Offset(, 1)
  14.         If [E2] = "" Then
  15.             If St = [E4] Then
  16.                 eR = [G65536].End(xlUp).Row + 1
  17.                 E.Resize(1, 3).Copy Cells(eR, 7)
  18.             End If
  19.         ElseIf [E4] = "" Then
  20.             If Dt >= Dt1 And Dt < Dt2 Then
  21.                 eR = [G65536].End(xlUp).Row + 1
  22.                 E.Resize(1, 3).Copy Cells(eR, 7)
  23.             End If
  24.         Else
  25.             If Dt >= Dt1 And Dt < Dt2 And St = [E4] Then
  26.                 eR = [G65536].End(xlUp).Row + 1
  27.                 E.Resize(1, 3).Copy Cells(eR, 7)
  28.             End If
  29.         End If
  30.     Next
  31. End Sub
  32. '²M°£
  33. Private Sub CommandButton2_Click()
  34.     [G2].Resize(Rows.Count - 1, 3) = ""
  35. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¨Ã«D¦³¿ú¾{¬O§Ö¼Ö¡A°Ý¤ßµL·\¤ß³Ì¦w¡C
ªð¦^¦Cªí ¤W¤@¥DÃD