Consulting

Results 1 to 6 of 6

Thread: Error: Compile Error

  1. #1

    Error: Compile Error

    Good morning!
    Trying to create this macro to place this function "=Left(B5, Find("~", B5) - 1)" into cell K5. I keep getting compile error. Any help will be appreciated.

    Sub DailyServiceFormula()
    Range("K5").Formula = "=Left(B5, Find("~", B5) - 1)"
    End Sub
    Last edited by mdmackillop; 07-10-2017 at 08:30 AM. Reason: Code tags added

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    >Find("~",

    Find(""~"",

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Range("K5").FormulaR1C1 = "=LEFT(RC[-9], FIND(""~"", RC[-9]) - 1)"
    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
    Thank you!
    Works like a charm.

  5. #5
    @P45cal, thank you for the formula.
    How did you get the -9? or Did excel gave it to you?

  6. #6
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by EdwardOcampo View Post
    @P45cal, thank you for the formula.
    How did you get the -9? or Did excel gave it to you?
    It is 9 columns to the left of column K since you have relative references throughout.
    Yes, Excel gave it to me when I recorded a macro of me putting your formula into cell K5.
    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
  •