Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 8 of 8

Thread: Enter Formula With VBA

  1. #1
    Join Date
    13th July 2004
    Posts
    373

    Enter Formula With VBA

    I previously requested help and several folks helped me out. I've found that if I can convert to a VBA It would be easier. I can record the Macro but was wondering if anyone had any better ideas. Heres the formula I'm trying to work into a macro using VBA. Thanks

    = DATE(LEFT(J3,4)+CHOOSE(MATCH(B3,{"CAPT","CDR","LCDR"}),38,35,30),MID(J3,5,2),RIGHT(J3,2))

    THanks very much
    Billyj

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    19th January 2005
    Location
    Michigan, USA
    Posts
    844

    Re: Use Formula In Vba

    You can't use that formula?

    VB:
    Range("C1").Formula = "=sum(A1:B1)" 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    13th July 2004
    Posts
    373

    Re: Use Formula In Vba

    Thanks for the quick response. But I honestly do not know how to apply what you are saying. Thanks again

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    19th January 2005
    Location
    Michigan, USA
    Posts
    844

    Re: Use Formula In Vba

    VB:
    Range("A1").Formula = "=DATE(LEFT(J3,4)+CHOOSE(MATCH(B3,{"CAPT","CDR","LCDR"}),38,35,30),MID(J3,5,2),RIGHT(J3,2))" 
    
    
    ...would place your exact formula into cell A1.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    13th July 2004
    Posts
    373

    Re: Use Formula In Vba

    Sorry brain burp.. I understand. Thanks

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,322

    Re: Use Formula In Vba

    You need to double up the interior quotes:
    VB:
    Range("A1").Formula = _ 
    "=DATE(LEFT(J3,4) + CHOOSE(MATCH(B3, {""CAPT"",""CDR"",""LCDR""}), 38,35,30), MID(J3,5,2), RIGHT(J3,2))" 
    
    
    Entia non sunt multiplicanda sine necessitate.
    MS MVP - Excel

  7. #7
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    31,698

    Re: Enter Formula With VBA

    I can record the Macro but was wondering if anyone had any better ideas
    That IS the best way, the Macro Recorder wont lie

  8. #8
    Join Date
    13th July 2004
    Posts
    373

    Re: Enter Formula With VBA

    Thanks everyone. I have used the recorder as well as your advice. I appreciate the help.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Vba Code To Enter Formula
    By angshuman in forum EXCEL HELP
    Replies: 3
    Last Post: August 28th, 2007, 00:00
  2. Enter Formula With VBA Code
    By angshuman in forum EXCEL HELP
    Replies: 4
    Last Post: August 27th, 2007, 11:46
  3. enter a formula from VB containing quotes
    By neverland in forum EXCEL HELP
    Replies: 1
    Last Post: March 9th, 2005, 22:17
  4. Enter Formula Into Cell
    By kokken in forum EXCEL HELP
    Replies: 3
    Last Post: October 31st, 2004, 10:04

Bookmarks

Posting Permissions

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