Question Locked

Excel Visual Basic

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello everyone

I,m in a bit of a pickle and wondering could anyone help please. I have been asked to create a visual basic programme in excel and as I have never used it before I'm struggling. I thought with the ever mighty internet I may be able to sort something out but nothing so far.
I need to come up with something based on Ohms law i.e input the voltage and current and the programme then tells you the resistance and the wattage of the item.
Every thing I've tried is useless. Could anybody point me in the right direction with this. Any help would be greatly appreciated.
Thanks in advance

8 replies

by computercookie

post your code first.

A good programmer could look at your code and easily modify it.

A good programmer could look at your question and he doen't know Ohm's Law!!!!

Your problem slacko.

by scouser42

Hi Jimmy Jam

Yes it has to be visual basic and thanks for replying

by jiminpa

Open Excel - hit Alt + F11
Visual Basic Editor comes up.
Right click on sheet1 and insert user form.
Drag two textbox's and a command button on to the form.
Double click on the command button and the script editor will pop up.
Insert the following code.

Voltage = TextBox1.Text
Current = TextBox2.Text
Resistance = Current / Voltage
Power = Voltage * Current
MsgBox ("Resistance = " & Resistance & vbCr & "Power = " & Power)

Save it. Push the green triangle at the top for the visual basic editor to trial run the form. Input your numbers and you should get a pop up with the values you are looking for.

Note: The above code will only come out right if you make textbox1 volts and textbox2 current. Also you will need to play getting it to launch when you open the workbook. There are some setting which I am not familiar with to get it to launch. If you continue to have problems post back or PM me and I'll see what I can come up with. Good luck.

by scouser42

Thank you both so much. Jimmy Jam I'll give it a try and let you know although it will probably be tomorrow that I will be in touch.
Best regards

This discussion is closed to new replies.