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

[µo°Ý] ¦h±ø¥óªºVLOOPUP

³o­Ó¥ÎVLOOKUP¤Ó½ÆÂø¤F
¥ÎVBA³B²z¥i¯à·|¤ñ¸û²³æ

TOP

¸Õ¸Õ³o­Ó
  1. Sub copydata()
  2. Dim s1 As Long, s2 As Long, s3 As Long, d1 As Long, d2 As Long
  3. Dim wages As Long, OT As Long

  4. i = 1
  5. While Sheets(1).Cells(i, 1) <> "Á~ª÷"
  6.     i = i + 1
  7. Wend
  8. wages = i

  9. While Sheets(1).Cells(i, 1) <> "¥[¯Z"
  10.     i = i + 1
  11. Wend
  12. OT = i

  13. For i = wages To Sheets(1).UsedRange.Rows.Count
  14.     s1 = Left(Sheets(1).Cells(i, 2), 4)
  15.     s2 = Mid(Sheets(1).Cells(i, 2), 6, InStr(1, Sheets(1).Cells(i, 2), "¤ë") - 5 - 1)
  16.     If InStr(1, Sheets(1).Cells(i, 2), "-") <> 0 Then
  17.         s3 = Mid(Sheets(1).Cells(i, 2), InStr(1, Sheets(1).Cells(i, 2), "-") + 1, Len(Sheets(1).Cells(i, 2)) - (InStr(1, Sheets(1).Cells(i, 2), "-") + 1))
  18.     Else
  19.         s3 = 0
  20.     End If
  21.     For j = 2 To Sheets(2).UsedRange.Rows.Count
  22.         d1 = Left(Sheets(2).Cells(j, 1), 4)
  23.         d2 = Mid(Sheets(2).Cells(j, 1), 6, InStr(1, Sheets(2).Cells(j, 1), "¤ë") - 1 - 5)
  24.         
  25.         If d1 * 100 + d2 >= s1 * 100 + s2 Then
  26.             If s3 <> 0 Then
  27.                 If d1 * 100 + d2 <= s1 * 100 + s3 Then
  28.                     If i >= OT Then
  29.                         Sheets(2).Cells(j, 3) = Sheets(1).Cells(i, 3)
  30.                     Else
  31.                         Sheets(2).Cells(j, 2) = Sheets(1).Cells(i, 3)
  32.                     End If
  33.                 End If
  34.             Else
  35.                 If i >= OT Then
  36.                     Sheets(2).Cells(j, 3) = Sheets(1).Cells(i, 3)
  37.                 Else
  38.                     Sheets(2).Cells(j, 2) = Sheets(1).Cells(i, 3)
  39.                 End If
  40.             End If
  41.         End If
  42.     Next j
  43. Next i
  44. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¡i®É¤é²öªÅ¹L¡j¤@­Ó¤H¦b¥@¶¡°µ¤F¦h¤Ö¨Æ¡A´Nµ¥©ó¹Ø©R¦³¦hªø¡C¦]¦¹¥²¶·»P®É¶¡Ävª§¡A¤Á²ö¨Ï®É¤éªÅ¹L¡C
ªð¦^¦Cªí ¤W¤@¥DÃD