返回列表 上一主題 發帖

[發問] 搜尋、比對,再複製過來的功能

如果只是簡單查詢, 資料也不多, 可用公式:
Sub 巨集1()
P$ = ThisWorkbook.Path & "\"
With Range("D2", Cells(Rows.Count, 1).End(xlUp)(2, 2))
     .Columns(1) = "=VLOOKUP(A2,'" & P & "[資料.xlsx]工作表1'!A:D,2,)"
     .Columns(3) = "=VLOOKUP(A2,'" & P & "[資料.xlsx]工作表1'!A:D,4,)"
     .Columns(2) = "=VLOOKUP(A2,'" & P & "[尺寸.xlsx]工作表1'!A:D,2,)"
     .Value = .Value
     .Replace "#N/A", ""
End With
End Sub

TOP

回復 13# iceandy6150

年資??? 可能有如下情形???
1年3月5日
1年5月
1年12日
5月18日
3月
29日

TOP

回復 13# iceandy6150

Private Sub CommandButton1_Click()
c$ = Replace(Replace(Range("A1"), "年", ":"), "月", "")
If IsNumeric(c) Then c = "0:" & c
c = Application.Text(c, "[hh]年mm月")
Range("B1") = c
End Sub

======================

TOP

回復 15# n7822123


Private Sub CommandButton2_Click()
d& = Evaluate("edate(" & CLng(Date) & ", 1)")
ym$ = Format(d, "emm") & "檔案"
MsgBox ym
End Sub

TOP

回復 15# n7822123

Private Sub CommandButton2_Click()
d = CDate(Format(Now, "yyyy/m/1")) + 31
ym$ = Format(d, "emm") & "檔案"
MsgBox ym
End Sub

TOP

再來兩種方法:
Private Sub CommandButton2_Click()
ym$ = Format(Date - Day(Date) + 32, "EMM") & "檔案"
MsgBox ym
End Sub


Private Sub CommandButton2_Click()
ym$ = Format(DateAdd("m", 1, Date), "EMM") & "檔案"
MsgBox ym
End Sub


===========================

TOP

        靜思自在 : 發脾氣是短暫的發瘋。
返回列表 上一主題