Excel Macros

By raharr ·
I am trying to write a macro in Excel that kind of goes like this.

If Cell X = 001, 002 or 003 then Cell XX will be WL, BW or DET.

Anyone have any ideas? I used Case Select and can not get it to fill in Cell XX with what I want.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

re: Excel Macros

by ThumbsUp2 In reply to Excel Macros

Excel does not actually store leading zeros in a numeric field. If you want to search for "001", you have to define the cells as text cells and make sure the zeros are present when you look at the contents of the cell in the formatting line.

Collapse -

Excel Macro

by raharr In reply to re: Excel Macros

I have done that, but I can not seem to get it to post what I want in a different cell.

Collapse -

re Macro help

by ThumbsUp2 In reply to Excel Macro

Not exactly sure what it is you're saying. Are you saying it won't write the correct thing in cell XX, or it won't write in cell XX at all and writes somewhere else?

You must use the active cell offset, or move the active cell to XX before you can write IN that cell.

Can you give an example of the code you're using and maybe we can decipher it for you? Be specific on what it is you want it to do.

Collapse -


by Bizzo In reply to Excel Macro

Maybe I'm being a little naive here, but if it's only 3 choices can't you use embedded IF's?


Collapse -

That works......

by ThumbsUp2 In reply to =IF(...)

That formula works for me, but ONLY if you type '001 in cell A1. You must type the ' character before the number to force it to be text. If I simply type 001 into cell A1, the formula displays a blank, which is what it SHOULD do. And, that's what I was trying to tell you. Excel will NOT store the leading zeros in the cell unless you type ' first before the number.

By the way. That is not a MACRO. That is a FORMULA. The two are completely different.

Collapse -

I know it's a formula

by Bizzo In reply to That works......

I wasn't clear in my post, I meant to say that seeing as it's only 3 choices, is it necessary to use a macro, why not a formula.

Collapse -

Sorry.... didn't see it was you

by ThumbsUp2 In reply to I know it's a formula

Didn't see it was you replying to OP. Thought it was him showing what he had done already, so I corrected "him"....

Thummy had not had enough coffee yet!

Collapse -


by Bizzo In reply to Sorry.... didn't see it w ...

No problem.

Remember: Coffee first, then keyboard!

Collapse -

Excel Formula

by raharr In reply to I know it's a formula

Got it! Thanks!

You were correct. I used a formula and not a macro.


Related Discussions

Related Forums