+ Reply to Thread
Results 1 to 10 of 10

return weekday name using text function in vba

  1. #1
    Forum Contributor
    Join Date
    01-06-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    118

    return weekday name using text function in vba

    HI,

    I wrote below code (with in for loop )to display weekday name using text function. (based on excel formula)

    Sheet2.Cells(2, i + 2).value = worksheetfunction.text(date(sheet1.Cells(2,1).value,sheet1.cells(2,2).value,Sheet2.Cells(3, i + 2).value),"ddd")



    if i=1 then , i want to get day name at shee2.cells(2,3).value=Wed ( if the date is 1-02-2017)

    sheet1.Cells(2,1).value = 2017
    sheet1.cells(2,2).value= Feb
    Sheet2.Cells(3, i + 2).value=1

    but above text function is not wokring. error showing at "sheet1" and Error is : Compile Error , Expected: )

    regards
    shiva

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: return weekday name using text function in vba

    Wel Feb is not a know Excel function

    Should be "Feb"
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: return weekday name using text function in vba

    Well, the whole this is well, bad.

    the correct code as goes for syntax:

    Please Login or Register  to view this content.
    And Feb will not be recognized,

  4. #4
    Forum Contributor
    Join Date
    01-06-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    118

    Re: return weekday name using text function in vba

    thanks for reply. but the above dateserial function retruns Run time Error 13: type mismatch

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: return weekday name using text function in vba

    Hello
    The line of code in post #3 is correct. May be there is something wrong in your sheets' names. Make sure they are correct
    Or upload sample of your workbook to be easier for others to help you out
    Regards
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  6. #6
    Forum Contributor
    Join Date
    01-06-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    118

    Re: return weekday name using text function in vba

    Hi YasserKhalil,


    Pls find the attachment.


    regards
    shiva
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: return weekday name using text function in vba

    May be using UDF to convert the strings in B2 (Jan, Feb ...) to numbers
    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: return weekday name using text function in vba

    Change to
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-06-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    118

    Re: return weekday name using text function in vba

    Thank you YasserKhalil Ji.

  10. #10
    Forum Contributor
    Join Date
    01-06-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    118

    Re: return weekday name using text function in vba

    Thank you very much Jindon.......

+ 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: 6
    Last Post: 11-02-2016, 09:54 AM
  2. Excel VBA code to return weekday name from a date then autofilters for userdefined weekday
    By studyengineering in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2016, 03:24 PM
  3. [SOLVED] Use a Sum If weekday function to return hours worked by day of week
    By jbeets in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-19-2015, 07:45 PM
  4. Return dates based on julian weekday only calendar
    By jguzman1990 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-18-2015, 05:01 PM
  5. [SOLVED] Return Future Weekday
    By sports_fan in forum Excel General
    Replies: 6
    Last Post: 01-10-2013, 01:08 AM
  6. Return date for the next coming weekday
    By ElmerS in forum Excel General
    Replies: 7
    Last Post: 05-24-2010, 12:51 PM
  7. Add a number to date and return a weekday
    By dwain in forum Excel General
    Replies: 3
    Last Post: 10-13-2008, 10:55 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