Save files in accordance of month etc
Results 1 to 8 of 8

Thread: Save files in accordance of month etc

  1. #1
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,323
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Save files in accordance of month etc

    Evening.
    I have supplied the code below that is in use & works as it should.


    Code:
    Private Sub GrassSummarySheet_Click()    Dim strFileName As String
        
        strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\" & Range("A3") & " " & Range("D3") & ".pdf"
        If Dir(strFileName) <> vbNullString Then
            MsgBox "GRASS SHEET " & Range("A3") & " " & Range("D3") & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly, "SUMMARY GRASS SHEET MESSAGE"
            Exit Sub
        End If
        
        With ActiveSheet
            .ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True
            MsgBox "GRASS SHEET " & Range("A3") & " " & Range("D3") & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "SUMMARY GRASS SHEET MESSAGE"
            Range("A5:B41").ClearContents
            Range("A5").Select
            ActiveWorkbook.Save
        End With
    End Sub
    All the above works fine but i need to think about how the files etc look in the saved foler.
    I mean currently i see this
    APRIL,JUNE,MAY

    As the months sheets are added i will see December towards the very start.

    I cant explain things correctly but if they could be save with a number in front the it would be in the correct order in the saved folder like so,
    04 APRIL
    05 MAY
    06 JUNE
    07 JULY
    08 AUGUST
    09 SEPTEMBER
    10 OCTOBER
    11 NOVEMBER
    12 DECEMBER
    13 JANUARY
    14 FEBRUARY
    15 MARCH
    16 APRIL
    This would be the full year save in the correct month order as the numbers would be save in the numerical sequence.

    Otherwise it will be like,
    APRIL
    AUGUST
    DECEMBER
    JANUARY
    JUNE
    JULY
    etc etc

    many thanks
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

  2. #2
    Board Regular
    Join Date
    Mar 2013
    Posts
    698
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    What's in A3 and D3 ?

  3. #3
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,323
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    A3 Is the month
    D3 is the year
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

  4. #4
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,323
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    I needed the save file like JULY 2019 but spending some time today it was everything but so had to split them up
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

  5. #5
    Board Regular
    Join Date
    Mar 2013
    Posts
    698
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    How about saving them the other way around
    Code:
        strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\" & _
                      Range("D3") & "_" & Format(Month(DateValue(Range("A3") & " 1, " & "2019")), "00") & " " & Range("A3")

  6. #6
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,323
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    Nice but not quite.
    Reason being June & July come before May
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

  7. #7
    Board Regular
    Join Date
    Mar 2013
    Posts
    698
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    After you added the file extension, were the file names not
    2019_05 May.pdf
    2019_06 June.pdf
    2019_07 July.pdf

  8. #8
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,323
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Save files in accordance of month etc

    Sorry my mistake.
    yes you are correct it works fine.

    Thanks
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •