I ran into a little bug while running one of my macros this morning. After doing a bit of investigating I found that the problem was due to this line:
The problem was due to the fact that earlier, I had been doing some 'non-macro' replacing through the find/replace dialog, and I had selected 'workbook' in the 'replace within' option. So when I later ran my code, it deleted all of the space characters in the entire workbook. Once I selected 'sheet' instead of 'workbook' the macro worked fine.
Once I give this macro to other users I don't want them to encounter the same problem, so I was wondering if anyone knew how to specify that i want to search only in the current sheet not the entire workbook. i thought that by searching within a range as my code should do, that it would not matter, but evidently it does.
Thanks
Code:
Range("b2:b" & Range("a1048576").End(xlUp).Row).Replace what:=" ", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
The problem was due to the fact that earlier, I had been doing some 'non-macro' replacing through the find/replace dialog, and I had selected 'workbook' in the 'replace within' option. So when I later ran my code, it deleted all of the space characters in the entire workbook. Once I selected 'sheet' instead of 'workbook' the macro worked fine.
Once I give this macro to other users I don't want them to encounter the same problem, so I was wondering if anyone knew how to specify that i want to search only in the current sheet not the entire workbook. i thought that by searching within a range as my code should do, that it would not matter, but evidently it does.
Thanks