Consulting

Results 1 to 5 of 5

Thread: VBA, i want the value, not the formula

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    VBA, i want the value, not the formula

    Hi, the following code places a formula in a cell for me which returns the desired result.

    Trouble is, I want the code to put the value in there, not the formula

    Sub LookupTalkNumber()
    Dim TalkNumber$
          
        'get the talk number that was just entered
       TalkNumber = Format(ActiveCell.Value, "0")
        
        Cells(53, ActiveCell.Column).Formula = "= vlookup(" & TalkNumber & ", PublicTalkTitles!$A$2:$K$201, 11, FALSE)"
    
    End Sub
    How do I do it please?

    Many thanks

    Sir BD
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    So I solved it with
    With Cells(53, ActiveCell.Column)
        .Value = .Value
    End With
    And that's fine, but I'd still like to know how to use vlookup to put the result straight in.

    Thanks
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,877
    not tested:
    Cells(53, ActiveCell.Column).value =application.vlookup(TalkNumber, Sheets("PublicTalkTitles").range("A2:K201"), 11, FALSE)
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    Thanks for the reply

    Tried that but it returns "#N/A"

    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,877
    Does it work if you:
    Dim TalkNumber
    TalkNumber = ActiveCell.Value

    $ removed from TalkNumber variable name, and no formatting applied to the activecell value (so that it stays as a number (I don't know what's in the first column of that table)).
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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