+ Reply to Thread
Results 1 to 3 of 3

How to write a Find and and Mid function in vba?

  1. #1
    Forum Contributor
    Join Date
    05-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    184

    How to write a Find and and Mid function in vba?

    I wrote this for loop to loop through my outlook subfolder and find e-mail with attachments and save it to a specific folder. It also look at the subject line of the e-mail and exact invoice number. Basically it find the location of "#" in the subject line and and pull the invoice 8 digits after that # character.

    This is the line of code that doesn't caused the error. I think it has to do with the "#". Can someone show me how to write this line of code correctly?

    InvoiceNumber = Mid(Item, Find("#", Item) + 1, 8)


    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to write a Find and and Mid function in vba?

    Please Login or Register  to view this content.
    Above is the syntax for the worksheet function FIND. It is not applicable in VBA.

    The equivalent in VBA is Instr

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    05-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    184

    Re: How to write a Find and and Mid function in vba?

    I tried it and it works. Thank you so much for your help.

+ 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. Replies: 3
    Last Post: 04-09-2015, 08:00 PM
  2. [SOLVED] RE-write if function with isna function for more values
    By funtastic in forum Excel General
    Replies: 6
    Last Post: 07-12-2012, 04:33 AM
  3. Search-find-write
    By smaill_19 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-19-2010, 03:31 AM
  4. [SOLVED] how to write function to find max deviation from specific number .
    By barbdee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-15-2005, 11:15 PM
  5. Find and write
    By mtahir in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-04-2005, 10:05 AM
  6. [SOLVED] how do I write a vlookup function within an iserror function so t.
    By JBLeeds in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2005, 07:06 AM
  7. [SOLVED] Find and Write data
    By James W. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2005, 09:06 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