+ Reply to Thread
Results 1 to 5 of 5

Convert Excel formula to VBA code

  1. #1
    Registered User
    Join Date
    04-27-2023
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    30

    Lightbulb Convert Excel formula to VBA code

    Hello,

    In the factory where I work, we use the "Julian Day" calendar to list our batches.

    By Excel I got the formula below that when I write the date 12/01/2023 (were we use day, month and year) it returns me the year and the letter "V" (that is necessary for our process) and the referent date of the "Julian Day" calendar

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thus, 12/01/2023 = 23V043

    But I would need to apply this formula inside the userform, according to the attached file.

    Can someone help me?

    TEST.xlsm
    convert-date-to-julian.xlsx
    Last edited by jujuaurich; 04-28-2023 at 03:06 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Convert Excel formula to VBA code

    Hello.
    In your example we must assume that you wanted to write February 12 and not January 12, right?...

    Because that's what results from the day: 23V043.
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  3. #3
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Convert Excel formula to VBA code

    And regarding the requested VBA code, try with:

    PHP Code: 
    Private Sub Inserir_Click()
    Dim fe As Date
    fe 
    CDate(Tbbatatidas)
    Tbproducao Right(Year(fe), 2) & "V" Format(fe DateSerial(Year(fe), 10), "000")
    End Sub 

  4. #4
    Registered User
    Join Date
    04-27-2023
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    30

    Re: Convert Excel formula to VBA code

    A thousand apologies, now that I realize the typo.

    You are correct!

    I have attached in the first post the conversion spreadsheet along with test.

  5. #5
    Registered User
    Join Date
    04-27-2023
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    30

    Re: Convert Excel formula to VBA code

    Thank you very 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. [SOLVED] Need help to convert formula into code and place it in the existing code.
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2022, 03:31 PM
  2. [SOLVED] Need to convert one formula into code and add it to the existing code
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-03-2022, 04:23 PM
  3. Convert Excel Formula to VBA Code
    By Jalica in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-10-2019, 01:17 PM
  4. [SOLVED] Convert Excel formula into VBA code
    By Grumpy9215 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-20-2017, 04:40 AM
  5. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  6. [SOLVED] Convert Excel formula to VBA code
    By Grumpy9215 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2012, 03:49 PM
  7. Convert Excel Formula to Macro Code
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2009, 10:14 PM

Tags for this Thread

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