Excel programming

  • Thread starter Thread starter Surya
  • Start date Start date
S

Surya

Hi,

I am new to programming and I would like to know how to
do some automation in MS-Excel.

For example in Column A I would type some questions for
which user need to answer in column B for each question.
When they answer a question and leaves the cell I should
be able to evaluate whether the answer is true or false
and display the same in Column C.

When user open the excel file user will be seeing only
question in column A, when he types in answer in Column B,
it has to evaluated and result has to be displayed in
column C
A B C
No. of Months in a Year 12 true
No. of weeks in a Year 2 false

Could someone help me out with an example or links to
help me know how to achieve this kind of requirement
 
Hi Surya,
What you want to achieve is not really difficult to do with some VBA coding.
But until you've some sort grasp of the excel object model and VBA, codes
from others will only perplex you. If you're just starting out, I'd
recommend you to go through some tutorials. This page has got links for
everyone: http://www.mvps.org/dmcritchie/excel/excel.htm

If you already know the basics, then ignore this post. someone will come
along with the code.

Good luck.
~Asif
 
You can do this with a formula in column C

For example, in C2

=if(B2="","",if(B2=12,True,False))

You can also shorten it to
=if(B2="","",if(B2=12,True))
 
Or even

=if(B2="","",B2=12)

--
Best Regards
Leo Heuser
Excel MVP

Followup to newsgroup only please.
 
Hello Surya,

This can be done even without VB.

First, write a formula in C that will evaluate if the answer is correct.
Assume that question and answer are in A1 and B1 respectively then write the
formula in C1 as =IF(B1="","",B1=12). If the correct answer is not number,
you must enclose it in quotation marks. i.e =IF(B1="","",B1="ABC").

Second, protect your worksheet. Select all the cells that user will use to
put their answers. In Format>Cells>Protection Tab uncheck "locked". Now
select all the cells that you have put your formula. In
Format>Cells>Protection Tab check "hidden" to prevent them in seeing the
correct answers. Perhaps, you already know that you need to go
Tools>Protection>Protect Sheet because if you have notice this is noted in
Format Cells Dialog box.

If you still wish to use VB, sad to say I am only one of the ordinary guy.
But, if you just wait a while experts in this NG could help you.

Regards,

Jon-jon
 
Back
Top