- ©«¤l
- 17
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 24
- ÂI¦W
- 0
- §@·~¨t²Î
- windwo10
- ³nÅ骩¥»
- excel2013
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2017-1-7
- ³Ì«áµn¿ý
- 2023-2-18
|
[µo°Ý] VBA VLookup¤¹³\¥Î¤á¿ï¾Ü¥Ø¿ý¤Wªº¤å¥ó¦W
§Ú¦b¦bºôµ¸¤W§ä¨ì³oÓ°ÝÃD(¬ÝPartA) ¥LÌ»¡: Set myFile = Application.GetOpenFilename ¤£¯à¦^¶Ç¤@Óobject.
¤§«á¦³¤H¸Ñµªn¨Ï¥Î¥H¤UB³¡¥÷.¥hקï...¥i¬O§Ú¤£À´n¦p¦óקï , ¦³¤H¯à¸Õ¤@¤U¶Ü?- Sub VlookupMacro()
- Dim FirstRow As Long
- Dim FinalRow As Long
- Dim myValues As Range
- Dim myResults As Range
- Dim myFile As Range
- Dim myCount As Integer
- Set myFile = Application.GetOpenFilename("Excel Files (*.xlsx), *.xlsx")
- Set myValues = Application.InputBox("Please select the first cell in the column with the values that you're looking for", Type:=8)
- Set myResults = Application.InputBox("Please select the first cell where you want your lookup results to start ", Type:=8)
- Range(myResults, myResults.Offset(FinalRow - FirstRow)).Formula = _
- "=VLOOKUP(" & Cells(FirstRow, myValues.Column) & ", myFile.value($A$2:$B$U20000), 5, False)"
- If MsgBox("Do you want to convert to values?", vbYesNo) = vbNo Then Exit Sub
- Columns(myResults.Column).Copy
- Columns(myResults.Column).PasteSpecial xlPasteValues
- Application.CutCopyMode = False
- End Sub
½Æ»s¥N½X ===============================================
B³¡:- FileName = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsx), *.xlsx", Title:="Please select a file")
- If FileName = False Then
- ' User pressed Cancel
- MsgBox "Please select a file"
- Exit Sub
- Else
- Workbooks.Open Filename:=FileName
- End If
½Æ»s¥N½X |
-
-
vlookup.zip
(21.25 KB)
|