Consulting

Results 1 to 7 of 7

Thread: Divide a value by a cell

  1. #1
    VBAX Regular
    Joined
    May 2005
    Posts
    75
    Location

    Divide a value by a cell

    Hi,

    Thanks for your help. Now, I continue my work but I have a new problem
    when I divide a value of cell

    Please have a look at my code (sheet2)

    In a few word, it looks something like this

    Dim valB As Long
        valB = Worksheets("Sheet1").Range("B1").Value
            sFormula = "((H" & i & "/& valB &"))"
            Cells(i, "I").Value = Evaluate(sFormula)

    But I receive a synthax error...

    What could I do?

    Thanks a lot

    Best regards,

    Fran?ois

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    sFormula = "(H" & i & "/" & valB & ")"
    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
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by frade

    Dim valB As Long
    valB = Worksheets("Sheet1").Range("B1").Value
    sFormula = "((H" & i & "/& valB &"))"
    Cells(i, "I").Value = Evaluate(sFormula)
    Dim valB As Long
    valB = Worksheets("Sheet1").Range("B1").Value
    Cells(i, "I").Value = Range("H" & i) / valB
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    xld - [uvba]some info 4 u[/uvba] I took the liberty of adjusting your post, hope you don't mind.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by firefytr
    xld - [uvba]some info 4 u[/uvba] I took the liberty of adjusting your post, hope you don't mind.
    Not at all. Personally, for 2 or 3 lines the tags seem superfluous to me, but that is just my opiniion. But i wish you had fixed that Italic in the original at the same time.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by xld
    But i wish you had fixed that Italic in the original at the same time.
    Not italics, just part of the Quote tags byproduct.

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by firefytr
    Not italics, just part of the Quote tags byproduct.


    Of course, just looked odd with code
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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