Consulting

Results 1 to 4 of 4

Thread: Solved: Calculate 2 cells

  1. #1
    VBAX Tutor
    Joined
    Sep 2008
    Posts
    213
    Location

    Solved: Calculate 2 cells

    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....

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Lose the "And" . It is incorrect in this context. Also, I would not write a value and immediately use it in the code.
    [vba]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
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor
    Joined
    Sep 2008
    Posts
    213
    Location
    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?

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by maninjapan
    Also, how do you get your VBA to show like that?
    Use the green VBA button
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •