I'm working with Excel macros and I'd like to have a snippet of code that will import the current username into a cell. Make sense? Thanks for your help!
I started Excel. I pressed Alt+F11 to get into the VBE editor. I inserted a new module and entered the code. I put the cursor into Sub test() and pressed F8 to step thru. When the line cursor reached "End Sub", there was my username in Debug window ("Direktfenster").
If you do the same, we may determine, what went wrong.
I'm not sure what you mean by "import into a macro".
Thanks for the clarification on that. I basically got to where you did via this macro stuff, but I like your way better.
*Update* Ah, I needed to add one thing:
ActiveCell.Value = sUserName
You gave me everything I needed to get the username into a variable, I was just missing putting the variable out into the spreadsheet. Thanks for your help, this is exactly what I needed (see, I'm a total newbie, but somehow I figured out how to put it out to teh screen :)). Thanks again for your help.
Don't mention it; I'am glad to help you. I should have written sUserName into a Cell in my code, but I always have to think a least three times how to specify a Cell in Excel. Why I didn't use Msgbox (or was it MessageBox?) is beyond me.