返回列表 上一主題 發帖

一個期限顯示問題

回復  GBKEE
謝謝版大, 這是我所需要, 但忽然有個想法, 能否把輸入名稱改為年份加月份, 如啟動巨集, 在顯 ...
317 發表於 2013-9-4 17:48

我猜樓主要的可能是只要是該月份進貨的都要秀出來,
所以我參考 3# 將 5# 修改了一下 :
  1. Sub ex()
  2.   ym = InputBox("輸入入貨年月", , 201308)
  3.   Set Rng = Range("B:B").SpecialCells(xlCellTypeConstants)
  4.   For Each a In Rng
  5.     If IsDate(a) Then
  6.       If Format(Cells(a.Row, "B"), "yyyymm") = ym Then
  7.         stemp = IIf(mystr = "", "", Chr(10))
  8.         If Cells(a.Row, "H") <> "" Then
  9.           R = a.Row
  10.         Else
  11.           R = Cells(a.Row, "H").End(xlUp).Row
  12.           If R = Rng.Cells(1).Row Then R = R + 1
  13.         End If
  14.         mystr = mystr & stemp & "入貨日期 : " & Cells(a.Row, "B").Text & "  " & Cells(a.Row, "C") & "  到期日 : " & Cells(R, "H")
  15.       End If
  16.     End If
  17.   Next
  18.   MsgBox mystr
  19. End Sub
複製代碼

TOP

        靜思自在 : 自己害自己,莫過於亂發脾氣。
返回列表 上一主題