Advertisement
Guest User

touyakucheck.vba

a guest
Nov 11th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub Check
  2. With Sheets("Sheet1").UsedRange
  3.     s1Row = .Rows(.Rows.Count).Row
  4. End With
  5. timings=array("朝","昼","夕")
  6. CrDate=cdate("1900/01/01")
  7. PrDate=cdate("1900/01/01")
  8. Worksheets("Sheet1").Select
  9. for i=1 to s1Row
  10.     if instr(Cells(i,1).text, "年") Then
  11.         if CrDate<>cdate("1900/01/01") Then
  12.             PrDate=CrDate
  13.             for each timing in timings
  14.                 if len(Jisseki)-len(Replace(Jisseki,timing,""))<>1 then
  15.                     ErrOut Format((CrDate),"m月d日") &" " & timing & len(Jisseki)-len(Replace(Jisseki,timing,"")) & "回"
  16.                 end if
  17.             next timing
  18.         end if
  19.         CrDate=Cells(i,1).value
  20.         if PrDate<>cdate("1900/01/01") and  PrDate+1 <> CrDate then
  21.             for j=1 to datediff("d",PrDate, CrDate)-1
  22.                 ErrOut Format((PrDate+j),"m月d日") & " 無入力"
  23.             next j
  24.         end if
  25.         Jisseki=""
  26.     elseif instr(Cells(i,1).text, ":") Then
  27.         Jisseki=JIsseki & Cells(i,2)
  28.     end if
  29. Next i
  30. Worksheets("Sheet2").Select
  31. msgbox "完了しました"
  32. end sub
  33.  
  34. sub ErrOut(Arg)
  35. With Sheets("Sheet2").UsedRange
  36.     s2Row = .Rows(.Rows.Count).Row
  37. End With
  38. Worksheets("Sheet2").Cells(s2Row+1,1)=Arg
  39. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement