VBA如何在某一行查找到指定值的单元格并获取其列号赋予给变量?
初级纯菜鸟,东起西凑+修改了一段VBA宏,原本如下,使用正常,Sub宏1()''宏1宏'DimnumAsIntegernum=Cells(2,Columns.Count)...
初级纯菜鸟,东起西凑+修改了一段VBA宏,原本如下,使用正常,Sub 宏1()'' 宏1 宏'Dim num As Integernum = Cells(2, Columns.Count).End(xlToLeft).ColumnDim mum As Integermum = Range("N" & Rows.Count).End(xlUp).Row Range(Cells(2, 13), Cells(mum, 13)).Select Selection.Copy Cells(2, num + 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=FalseEnd Sub改为如下后,提示1004错误:方法range作用于对象_global时失败&第五行语法错误Sub 宏1()'' 宏1 宏'Dim num As Integernum = Cells(2, Columns.Count).End(xlToLeft).ColumnDim colSet findcell = Rows("1").Find("公式", LookAt:=xlWhole)col = findcell.ColumnDim mum As Integermum = Range("col+1" & Rows.Count).End(xlUp).Row Range(Cells(2, col), Cells(mum, col)).Select Selection.Copy Cells(2, num + 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=FalseEnd Sub求帮忙指正错误,谢谢!
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询