PDA

View Full Version : Solved: Calculate 2 cells



maninjapan
10-03-2008, 03:00 AM
Im trying to build a data entry spreadsheet involving P&L in USD, GBP and EUR. Ultimately Id like the proft in USD , (i input the exchange rate)

So far I have the following

If ComboBoxCurrency.Text = "EUR" Or _
ComboBoxCurrency.Text = "GBP" Then
Cells(NextRow, 6) = TextBoxPL.Text And _
Cells(NextRow, 7) = Cells(NextRow, 6) * Cells(NextRow, 5)
Else: Cells(NextRow, 7) = TextBoxPL.Text
End If

All the data comes up as is, except for 7, Obviously this is written incorrectly....

mdmackillop
10-03-2008, 06:13 AM
Lose the "And" . It is incorrect in this context. Also, I would not write a value and immediately use it in the code.
If ComboBoxCurrency.Text = "EUR" Or _
ComboBoxCurrency.Text = "GBP" Then
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = TextBoxPL.Text * Cells(NextRow, 5)
Else
Cells(NextRow, 7) = TextBoxPL.Text
End If

maninjapan
10-03-2008, 08:37 AM
Another day, another problem solved. thanks for your help. So you only need and in the conditions side then??

Also, how do you get your VBA to show like that?

mdmackillop
10-05-2008, 11:42 AM
Also, how do you get your VBA to show like that?
Use the green VBA button