excel vba - Run-time error '13': Type mismatch error code -


i'm using following code create column of data can use filter pivot table.

the code works flags "run-time error '13': type mismatch" code error. can me change code eliminate error message.

here code i'm using.

    sub negativepivot()          sheets("owssvr").select         columns("w:w").select         selection.clearcontents         range("w2").select         activecell.formular1c1 = "=table_owssvr[@[count zero]]"         range("w2").select         selection.autofill destination:=range("w2:w230"), type:=xlfilldefault         range("w2:w230").select         activewindow.smallscroll down:=-230         range("w1").select         activecell.formular1c1 = "negative results"      each cell in range("w2:w230")     if cell.value <= 0     cell.value = "negative"     else     cell.value = cell.value     end if     next     end sub 

avoid using .select or .activate as possible. check this , this other methods , reasons. also, in former link, check usage of with.

your code looks programmatically correct, try improving overall style. vba touchy degree.

sub negativepivotmod()      sheets("owssvr")          .range("w:w").clearcontents          .range("w2")             .formular1c1 = "=table_owssvr[@[count zero]]"             .autofill destination:=.range("w2:w230"), type:=xlfilldefault         end          range("w1").formular1c1 = "negative results"          each cell in .range("w2:w230")             if cell.value < 0                 cell.value = "negative"             end if         next      end  end sub 

let know if helps.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -