Sub omnama()
ActiveSheet.Range(Cells("$1", "$A"), Cells("$39930", "$Q"))._
RemoveDuplicates Columns:=Array(1, 2, 6, 7, 8, 9), Header:=xlYes
End Sub
这是删除我看过的重复项的代码,我的问题是, 我想给一个变量而不是数字
cells("$39930","$Q") should be replaced with the below code
cells("$variable"),"$Q")) but gives the error Type mismatch -- run time error 13
如何让它发挥作用? 如果我说
cells($variable,"$Q") ' says that invalid character
那么我如何为这些代码放置一个变量Value。请让我知道。谢谢你提前
答案 0 :(得分:1)
尝试这样的事情:
Sub omnama()
Dim intRow as integer
intRow = 39930
ActiveSheet.Range(Cells("$1", "$A"), Cells("$" & CStr(intRow), "$Q"))._
RemoveDuplicates Columns:=Array(1, 2, 6, 7, 8, 9), Header:=xlYes
End Sub