我是新手,正在寻找一些帮助。我这里有一个代码,它告诉我"case but select case“错误,但是我的case在"select case”和"end select“中,所以我不确定我做错了什么。
Sub codematch()
Dim wbk As Workbook
Select Case response = MsgBox("Is the cursor in the first cell of the column?", vbYesNo, "Code Finder")
Case condition1
If response = 6 Then
Set wbk = Workbooks.Open("C:\test.xlsm")
Call wbk
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'[test.xlsm]Sheet1'!C1:C2,2,0)"
Do Until ActiveCell = ""
Call wbk.Close(False)
Case condition2
If response = 7 Then
response = MsgBox("Position the Cursor in the correct location and try again", vbOKOnly)
End If
End Select
End Sub发布于 2017-12-16 09:17:34
坦率地说,你的大部分代码都是毫无意义的。谁在乎用户把光标放在哪里。
Sub codematch()
dim target as range
set target = range("B1") 'or whever you want to start
Dim wbk As Workbook
Set wbk = Workbooks.Open("C:\test.xlsm")
Target.FormulaR1C1 = "=VLOOKUP(RC[-1],'[test.xlsm]Sheet1'!C1:C2,2,0)"
do
set target = target.offset(1,0)
target.offset(-1,0).copy target
loop until target.offset(0,-1)=""
target.clear
target.parent.columns(target.column).cells.formula =
_target.parent.columns(target.column).cells.value 'convert to values
wbk.close false
end sub是我认为你想要做的
https://stackoverflow.com/questions/47824199
复制相似问题