+ Reply to Thread
Results 1 to 11 of 11

formula in Macro (=LEFT(A1,FIND(".",A1)-1))

  1. #1
    Registered User
    Join Date
    05-19-2014
    Posts
    35

    formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    I need this formula in excel macro "=LEFT(A1,FIND(".",A1)-1)", Please help.....

    A1 is a String by name Fhead

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,625

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Use InStr instead of Find.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    05-19-2014
    Posts
    35

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Hi Ben,
    I got error

    Run time error 5
    Invalid procure call or argument.

    Please help

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Please Login or Register  to view this content.
    Please click the * below if this helps

  5. #5
    Forum Contributor
    Join Date
    02-10-2012
    Location
    Newcastle upon Tyne
    MS-Off Ver
    Excel 2021
    Posts
    114

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Use double ""."" In VBA

    hope that helps

  6. #6
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Hi - you are making a common mistake – trying to use the name of a cell in a formula while in VBA. That works in Excel formulas but not in VBA.

    Try something like this instead. (I tested this with a simple SUB but it may work better for you as a FUNCTION.)
    Please Login or Register  to view this content.
    Or even better, calculate the position of the period first and check that it is not zero to avoid an error with LEFT
    Please Login or Register  to view this content.

    Hope this helps.
    - Stu

  7. #7
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    It occurs to me that maybe you were trying to make a formula to put into a cell.
    Was that your intention?

    My code above does the calculation within the macro itself.

    -Stu

  8. #8
    Registered User
    Join Date
    12-08-2017
    Location
    dallas
    MS-Off Ver
    ms office 2010
    Posts
    2

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Hello Stu,

    Great code ! This works perfectly well in my situation, but what if I want to include all the A column as a range of this code instead of just A1 cell.

  9. #9
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  10. #10
    Registered User
    Join Date
    12-08-2017
    Location
    dallas
    MS-Off Ver
    ms office 2010
    Posts
    2

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    Hello Stu,

    Great code ! This works perfectly well in my situation, but what if I want to include all the A column as a range of this code instead of just A1 cell.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,625

    Re: formula in Macro (=LEFT(A1,FIND(".",A1)-1))

    SAT007,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ 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. Use (LEFT(A4;FIND(" ";A4)-1) to count stock sold
    By Luther.King in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-02-2014, 12:02 PM
  2. Adding multiple "find" with "left" /"Right"
    By Daniel1 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 02-22-2014, 04:33 PM
  3. "left" , "right" or "mid" a range then find
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2013, 10:15 AM
  4. Developing a "Search" or "Find" Macro/ VBA Program
    By SamBevis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2013, 09:44 PM
  5. Applying a "Left" formula to an entire column with heading "ValueCol"
    By aad401 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2012, 04:14 PM
  6. Find "Total" and move one cell to left and copy down information
    By adgjqetuo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2009, 02:03 PM
  7. Replies: 5
    Last Post: 06-26-2006, 09:23 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