![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: iceland
Posts: 138
|
Hi guys.
Im new in vba, hope you can help me. What Im trying to do is. In my worksheet i have cellA1=3, cellA2=4. Also I have a button "calculate". What i want is, when i push "calculate" a new window pops up, wich says. value 1 is: 3 (cellA1) value 2 is: 4 (cellA2) Outcome is: 7 (cellA1+CellA2) (is it maybe possible to select value 1 and value 2 by using the mouse, that is by clicking in the cell). BK Stulli. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
Add a button to your sheet and assign the following macro to it.
Sub calc() msg = "Value 1 is: " & Range("A1").Value & Chr$(13) msg = msg & "Value 2 is: " & Range("A2").Value & Chr$(13) msg = msg & "Outcome is: " & Range("A1").Value + Range("A2").Value MsgBox msg End Sub
__________________
It's never too late to learn something new. Ricky |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
Sub calc() Dim msg As String msg = "Value 1 is: " & Range("A1").Value & Chr$(13) msg = msg & "Value 2 is: " & Range("A2").Value & Chr$(13) msg = msg & "Outcome is: " & Range("A1").Value + Range("A2").Value MsgBox msg End Sub
__________________
"Have a good time......all the time" Ian Mac |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: iceland
Posts: 138
|
this works fine, thank you guys.
also, can I make a userform, so that you can either type in a textbox Value1 and value2. or select them with your mouse?(by clicking,in the cells that contain value1 and value2, in your excelsheet) BK Stulli |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|