Consulting

Results 1 to 7 of 7

Thread: Combine two arguments into one.

  1. #1
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location

    Combine two arguments into one.

    Good afternoon,

    Both the below work on their own.
    How can I combine them into one line please.
    I have tried evaluate but without any success.

        Range("B10").Value = _
            Format(x, "###,###,###") & " ********* Generated In: " & _
            Format(((Timer - Start) / 24 / 60 / 60), "hh:mm:ss") & " Seconds"
        Range("M10").Value = "=If(SUM(C8:O8)-" & x & "=0,""Check: OK"",""Check: NOT OK"")"
    By that I mean taking out the...

    Range("M10").Value
    ...so it all goes in B10.

    Thanks in advance.
    Last edited by PAB; 01-24-2017 at 10:12 AM.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Q1: you want to combine the Range("B10").Value = and the Range("M10").Value = into one statement? Why?

    Q2: Shouldn't Range("M10").Value = be Range("M10").Formula?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Sorry, I didn't explain that very well.

    It should read something like this...

    12 ********* Genereated In: 00:00:00 Seconds > Check: OK

    ...or...

    12 ********* Genereated In: 00:00:00 Seconds > Check: NOT OK

    Thanks in advance.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Sorry, but still not 100% clear to me

    Maybe a user defined function would be a way to go



    Option Explicit
    
    Function test(X As Double, S As Double, R As Range) As String
        Dim sOut As String
        
        sOut = Format(X, "###,###,###") & " ********* Generated In: "
        sOut = sOut & Format(((Timer - S) / 24 / 60 / 60), "hh:mm:ss") & " Seconds: "
        
        'close enough to be equal
        If Abs(X - Application.WorksheetFunction.Sum(R)) < 10 ^ 5 Then
            sOut = sOut & "OK"
        Else
            sOut = sOut & "Not OK"
        End If
        test = sOut
    End Function
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Thanks for the reply Paul it is appreciated.

    I can go with that.
    I was actually trying to achieve it using the Concatenate function but without any success.
    I got close, but not close enough.
    I really just wanted to add the...

    "=If(SUM(C8:O8)-" & x & "=0,""Check: OK"",""Check: NOT OK"")"
    ...bit to the end of...

        Range("B10").Value = _
            Format(x, "###,###,###") & " ********* Genereated In: " & _
            Format(((Timer - Start) / 24 / 60 / 60), "hh:mm:ss") & " Seconds"
    Thanks again.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Dim ck As String
    
    If WorksheetFunction.Sum(Range("C8:O8")) = x then
    ck = " > Check: OK"
    Else
    ck = " > Check: NOT OK"
    End If
    
    Range("B10").Value = _ 
    Format(x, "###,###,###") & " ********* Generated In: " & _ 
    (Timer - Start) / 24 / 60 / 60) & " Seconds"  & ck
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Brilliant SamT, thanks very much.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

Posting Permissions

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