Results 1 to 18 of 18

Replacing whole date with only "Day" using for next loop or other methods.

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2019
    Location
    Mansehra, Pakistan
    MS-Off Ver
    2010
    Posts
    46

    Replacing whole date with only "Day" using for next loop or other methods.

    Hello Everyone!
    Hope you are safe and sound...

    In the column D of the sheet i attached, i have complete dates.
    I want to extract only the day and place that day in the same cell as of complete date, replacing the complete dates with day.
    and i want to do it for the whole column.
    I tried to solve this but type mismatch error arises. Please help...

    Sub Formulas()
    Const StartRow As Byte = 2
    Dim lastrow As Long
    Dim r As Long
    Dim MyDate As Double
    
    lastrow = Range("B3").CurrentRegion.Rows.Count
        For r = StartRow To lastrow
            MyDate = VBA.DateTime.Day("D" & r)
            Range("D" & r).Value = VBA.DateTime.Day("D" & r)
        
        Next r
    End Sub
    Please do note that, before using above code i also performed some other functions on this worksheet i.e deleting blank rows through filtering,
    For that i wrote another code first, after removing those blank rows, i wanted to change the complete dates in "Posting Date" column with only "Day".
    After filtering the blank rows, i have 109 rows, data starting from Row 2.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ideas and methods in improving "automatic calendar"???
    By Kamal1234 in forum Excel General
    Replies: 1
    Last Post: 08-24-2017, 11:08 AM
  2. Replies: 1
    Last Post: 01-22-2016, 09:21 AM
  3. Replacing "Yes" with End of Month Date
    By JMathur in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-25-2013, 12:03 AM
  4. Date format of just "st" "nd" "rd" and "th" with text included
    By notrandom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2013, 05:45 PM
  5. [SOLVED] Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.
    By staggers47 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-16-2013, 07:20 AM
  6. Return "green", "yellow" or "red" from date/age and priority ranking
    By Cantaloop in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2013, 12:12 AM
  7. [SOLVED] replacing sheet("XX").Select with for Loop Worksheet Name
    By Jerseynjphillypa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2012, 10:01 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