+ Reply to Thread
Results 1 to 8 of 8

Custom ExchangeRate function reference another workbook

  1. #1
    Registered User
    Join Date
    02-25-2017
    Location
    Belgrade
    MS-Off Ver
    2016
    Posts
    4

    Custom ExchangeRate function reference another workbook

    Idea is to make a custom function which i will install as an addin which will have a single argument (date) and fetch from a custom list exchange rate on that date. Basicly a vlookup.
    So far i have gotten this far:
    Please Login or Register  to view this content.
    Sheet "ExRate" contains two collumns, A collumn with a date B with Rate.

    Problem is date format, usually im typing them with dots so 25.02.2017 but the exrate sheet uses 25/02/2017 format which this setup cannot compare. I have noticed that data-> text to collumns has xlMDYFormat. MDY Date which manually works great for converting between the two date styles, but i failed replicating it in vba.
    How do i sanitize input so it can recognize 25.02.2017 as well as 25/02/2017 and also 25.2.2017?
    My solution so far is to just apend a new list with various date formats, but i would like to do it in code.
    Thanks in advance.
    Last edited by MarkoBox; 02-25-2017 at 02:42 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Custom ExchangeRate function reference another workbook

    Dot separator is a text not a date, so what you have is NOT DATE, but text-25.02.2017.

  3. #3
    Registered User
    Join Date
    02-25-2017
    Location
    Belgrade
    MS-Off Ver
    2016
    Posts
    4

    Re: Custom ExchangeRate function reference another workbook

    Im trying to find out how to convert it to date? As i said if i type it with dots (25.02.2017) and then use text to columns to convert it to date format it works fine. So how to do it with vba, i tried CDate() but it doesnt work.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Custom ExchangeRate function reference another workbook

    welcome to the forum

    Please Login or Register  to view this content.
    Last edited by kev_; 02-25-2017 at 03:09 PM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Custom ExchangeRate function reference another workbook

    Why are you using a dot to type( Enter) dates? I could understand if the dates are imported in to excel.

  6. #6
    Registered User
    Join Date
    02-25-2017
    Location
    Belgrade
    MS-Off Ver
    2016
    Posts
    4

    Re: Custom ExchangeRate function reference another workbook

    Thanks kev, i cant seem to get it to work it trows me expected array error despite me declaring all variables. I also found this solution, which seems to solve it:
    Please Login or Register  to view this content.
    Any advice on how to make it faster? I was thinking of putting it into array but my vba knowledge is limmited for it.

  7. #7
    Registered User
    Join Date
    02-25-2017
    Location
    Belgrade
    MS-Off Ver
    2016
    Posts
    4

    Re: Custom ExchangeRate function reference another workbook

    Quote Originally Posted by AB33 View Post
    Why are you using a dot to type( Enter) dates? I could understand if the dates are imported in to excel.
    On num keyboard .(del) key is much more easier to reach than slash, so everyone at work, including me type dates like that during manual entry.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Custom ExchangeRate function reference another workbook

    suggestion to speed it up:
    1. use a macro to convert all historic dates from 28.02.2016
    PLUS to ensure future typing is in correct date format
    2. "change event" macro that converts new dates when you edit a date cell
    Last edited by kev_; 02-25-2017 at 07:03 PM.

+ 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. Reference Custom or File Properties from an external workbook
    By dsl145 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 09:54 AM
  2. [SOLVED] Exchangerate
    By annupojupradeep in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-23-2014, 05:17 AM
  3. Problem with circular reference in a custom function
    By mongoose36 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-16-2014, 07:18 PM
  4. Need to reference existing functions in a custom function: possibl
    By dofnup in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. [SOLVED] Need to reference existing functions in a custom function: possibl
    By Max in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 06:05 AM
  6. Need to reference existing functions in a custom function: possibl
    By Max in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 04:05 AM
  7. [SOLVED] Need to reference existing functions in a custom function: possibl
    By dofnup in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

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