1

If I have a large range of cells, and I want to delete all cells containing just a "," or similar, how can I express this in code? I was thinking something along the lines of

If Range("C1:C100").Value = "," Then 
Active.Cell.Delete Shift:=xlRight 

I know this is terrible, but hopefully it gets my point across.

Thanks!

user1996971
  • 543
  • 5
  • 20
  • What happens when you try to run the code in your sample? Any error messages? You learn faster by doing it yourself and then asking questions about the problems you run into. :) – Olle Sjögren Sep 02 '15 at 09:47
  • Think about iterating through the cells in a given range... – Martin Milan Sep 02 '15 at 09:48
  • Thanks for the advice. I'm going to test telyln's answer a little bit and try figure out myself what's going on. I'll get back if I'm still stuck – user1996971 Sep 02 '15 at 10:58

1 Answers1

3

conceptually (not in front of Excel right now)

dim cel as range
for each cel in Range("C1:C100")
   if cel.Value = "," Then
      cel.Delete Shift:=xlRight 
   end if
next cel
teylyn
  • 34,374
  • 4
  • 53
  • 73