Excellent, excellent instructions!! Thanks a million!
A couple more questions, if I may. You answer several and that leads
to a couple more...
First, to answer yours, yes, the developer tools is excel 2007. I am
not fond of excel 2007; the color schemes confuse the heck out of me
and I can't ever get them set the way I want; the biggest advantage to
it is the increased number of rows, otherwise I'd probably have stayed
with 2003. I'm not much of an excel guru at all, but am a programmer
by trade on another platform so can usually figure things out like
this - with help from a real "techie" like you! THANKS!!! And even
if I plagiarize, he will know I got this from a kind soul and I didn't
write it myself.
Your instructions were great, outside of I had to get there through
the developer tab. Also, the "Application.worksheetfuntion.clean
corrected the problem I had too, was able to do the onkey code, and I
think everything is going to work.
But one other stupid question...since I haven't tested this yet (I
have to find some bogus data to do so with). Anyway, based on how I
read what you wrote, I would SELECT the range in my spreadsheet of
waht I want to run the DOCLEAN on and then once it's selected, do my
onkey to run it?? And it will run it on that range, correct? Is that
what the "Dim c As Range" does or is it the "If Selection.cells.count"
that makes it know I am working with only a selected cell area??? If
I wanted to arbitrarily do the entire sheet, then I could uncomment
the "ActiveSheet.UsedRange.Select" based on your documentation...
If I am interpreting your code, the "selection area" becomes "c" and
then the range "c" is what is processed???
Anyway, I have the code entered, saved as an add-in, and actually even
have it load now when I open excel and I I have it as a "control"
which I can just click on in my excel 2007 toolbar. Pretty slick.
Thanks so much, I think I will be able to get it the rest of the way
but I certainly couldn't have done it without your detailed
instructions!
smartin said:
George, if you continue to plagiarize my code I /expect/ to see your
name on the ballot (^: I am just kidding, of course -- you can do
anything you want with the code.
Now, I don't want to sound stupid either, but I am ignorant of the
"developer tools" pathway -- is that Excel 2007 speak? I am happily
stuck in 2003 so here is a way to install the code that should work in
any 21st century version of Excel. Apologies if these instructions seem
trivial, I'm just trying to cater to unknown levels of familiarity --
including my own.
Create a new, blank workbook. Press Alt+F11. This opens the VBA editor.
Note the "Project" browser is on the left (unless you have already
rearranged things), with your current workbook name highlighted. Go to
Insert | Module. A nice big white space opens up, and "Module1" appears
in the Project browser. Paste the code, your version, into the white space.
Ok I think you probably got this far already, but the code fails the
call to Clean(). Yes, Trim() is a native VBA function, and no, Clean()
is not. But Clean() is a worksheet function, and I believe it is the one
you want to use, so I think you can just replace that line with
c.Value = Application.WorksheetFunction.Clean(c.Value)
Try 'er again. Good? Good.
If you still want that hot key, add the last bit of code I posted to the
"ThisWorkbook" module. Double click "ThisWorkbook" in the Project
browser and paste in the code. You will of course want to change the
specifics to call DOClean using your favorite keystroke. Place the
cursor on the word "OnKey" and hit F1 for all the details.
Lastly, toggle back to the worksheet with Alt+F11 and file | save as | ,
change the type to add-in, name it and save it. Now you have your add-in
that contains the DoClean code and a hot key assignment to call it at
any time. Don't forget to add your add-in in tools | add-ins.
George Applegate
(e-mail address removed)