+ Reply to Thread
Results 1 to 5 of 5

VBA: How to make macro for typing specific (long) formula in cell ?

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    VBA: How to make macro for typing specific (long) formula in cell ?

    Hi guys,

    I'm trying to make a macro to type a formula presented in end of thread. Its very long formula, so I'd like a macro that could insert it (have to use the formula to update update quite frequently, it basically merges values from another document). I'm thinking I could assign the long formula as a variable or whatever and then just run it for a cell range whenever I wish.


    FYI, especially the " " in the formula gives me problems defining the formula as a variable - I'm not super experienced in VBA.

    this is the formula, probably doesn't make sense to you, but it works as for merging from another spreadsheet:

    =IF(IFERROR(YEAR(INDEX('[LE Smart Table2.xls]Sheet1'!$H$2:$H$2000;MATCH($C$2:$C$2000;'[LE Smart Table2.xls]Sheet1'!$E$2:$E$2000;0)))&" Q"&INT((MONTH(INDEX('[LE Smart Table2.xls]Sheet1'!$H$2:$H$2000;MATCH($C$2:$C$2000;'[LE Smart Table2.xls]Sheet1'!$E$2:$E$2000;0)))-1)/3+1);"")="1900 Q1";"";IFERROR(YEAR(INDEX('[LE Smart Table2.xls]Sheet1'!$H$2:$H$2000;MATCH($C$2:$C$2000;'[LE Smart Table2.xls]Sheet1'!$E$2:$E$2000;0)))&" Q"&INT((MONTH(INDEX('[LE Smart Table2.xls]Sheet1'!$H$2:$H$2000;MATCH($C$2:$C$2000;'[LE Smart Table2.xls]Sheet1'!$E$2:$E$2000;0)))-1)/3+1);""))

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA: How to make macro for typing specific (long) formula in cell ?

    You need to double up the quotes in the formula:


    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: VBA: How to make macro for typing specific (long) formula in cell ?

    Quote Originally Posted by TMS View Post
    You need to double up the quotes in the formula:


    Please Login or Register  to view this content.

    Regards, TMS
    TMS, thank you, the string works.

    Can you tell me how I make a macro that would insert the string in a specific cell?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA: How to make macro for typing specific (long) formula in cell ?

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA: How to make macro for typing specific (long) formula in cell ?

    Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need to make a UDF from a long formula
    By marksd80 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-17-2013, 02:31 PM
  2. Make a cell turn a color by typing a letter
    By stixmike in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-21-2012, 12:44 PM
  3. Replies: 5
    Last Post: 05-01-2012, 04:02 PM
  4. VBA macro to put Formula in cell - too long?
    By mac8528 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2010, 09:19 AM
  5. Replies: 1
    Last Post: 07-20-2006, 03:05 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1