How do i make the below syntax to work ( cells("$variable","Q"))?
Sub omnama()
ActiveSheet.Range(Cells("$1", "$A"), Cells("$39930", "$Q"))._
RemoveDuplicates Columns:=Array(1, 2, 6, 7, 8, 开发者_开发知识库9), Header:=xlYes
End Sub
This is the code to remove the duplicates I have seen and my question is, I wanna give a variable rather Than a number
cells("$39930","$Q") should be replaced with the below code
cells("$variable"),"$Q")) but gives the error Type mismatch -- run time error 13
How do I make it work? If i say
cells($variable,"$Q") ' says that invalid character
So how do i put a variable Value for these above code. Please let me know.Thank you in advance
Try something like this:
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
精彩评论