excel - Delete All Cells if not A-Z -


i working through 6 columns of data (a-f) rows 2-4379 , large number of cells appear "blanks" in filter column not true blanks seem contain spaces in them. hoping find vba examples finding cells within range contained ascii values between 65-90 , 97-122 , if values not contained within cell, clear completely.

is possible? have tried sub checked "istext" kept getting "sub or function not defined" error message relating istext line.

this have tried far:

dim c range dim rng range  set rng = range("a2:f4379")  each c in rng  if not istext(c.value) c.clearcontents end if  next c 

this should remove spaces active sheet:

option explicit  public sub trimwhitespaces()      activesheet.usedrange          .replace what:=" ", replacement:=vbnullstring, lookat:=xlwhole         .replace what:="  ", replacement:=vbnullstring, lookat:=xlwhole         .replace what:="   ", replacement:=vbnullstring, lookat:=xlwhole         .replace what:="    ", replacement:=vbnullstring, lookat:=xlwhole          .replace what:=vbtab, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbcrlf, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbcr, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vblf, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbnewline, replacement:=vbnullstring, lookat:=xlwhole          .replace what:=vbnullchar, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbback, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbformfeed, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbverticaltab, replacement:=vbnullstring, lookat:=xlwhole         .replace what:=vbobjecterror, replacement:=vbnullstring, lookat:=xlwhole      end  end sub 

.

as note:

your initial code had error because didn't include in sub()

you can fix using structure similar this:

option explicit  public sub testsub()     dim c range     dim rng range      set rng = range("a2:f4379")      each c in rng         if not istext(c.value)             c.clearcontents         end if     next end sub 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -