Format Dates

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys,

I came accross this code from Norie and it works fine!

However I like to format the dates in Wednesday 20 Feb 2019 and would love to have sundays automatically in red.

Code:
Sub FillDates()
    Dim StartDate As Date
    Dim EndDate As Date
    Dim NoDays As Integer

    With tabAuflistung
        StartDate = Range("B2").Value
        EndDate = Range("B3").Value
        
        NoDays = EndDate - StartDate + 1
        Range("A7").Value = StartDate
    
        Range("A7").Resize(NoDays).DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
            xlDay, Step:=1, Stop:=EndDate, Trend:=False

    End With
End Sub


I tried with format function but had no luck so far.

Help would be much appreciated!

Many Thanks

Albert
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Code:
Sub FillDates()
Dim StartDate As Date
Dim EndDate As Date
Dim NoDays As Integer
Dim cel As Range


'With tabAuflistung
    With Range([A7], [A7].End(xlDown))
        .Font.ColorIndex = xlAutomatic
        .ClearContents
    End With


    StartDate = Range("B2").Value
    EndDate = Range("B3").Value
    
    NoDays = EndDate - StartDate + 1
    Range("A7").Value = StartDate


    With Range("A7").Resize(NoDays)
        .DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
            xlDay, Step:=1, Stop:=EndDate, Trend:=False
        .NumberFormat = "dddd dd mmm yyyy"
    End With


    For Each cel In Range("A7").Resize(NoDays)
        If Weekday(cel) = 1 Then cel.Font.Color = 255
    Next
'End With
End Sub
Note :
The lines With tabAuflistung...End With​ are not doing anything and have been commented out in the code.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top