Sheet Naming Issue with Date Serial

cbzdmh

Board Regular
Joined
Jul 16, 2007
Messages
58
Hi All,

I have a pice of code running which has a variable named FTdate which returns a date in serial form, i need to name a new worksheet in the mmm-yy format, how do i convert from serial to the required string.

Any help appreciated.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I'm getting: run time errors

Rich (BB code):


For i = 1 To UBound(MyArr)

dDate = MyArr(i)
dDate = DateSerial(Year(dDate), Day(dDate), Month(dDate))
ldate = dDate

ws.Range("A1").AutoFilter Field:=1, Operator:=xlFilterValues, Criteria2:=Array(1, dDate)
Application.ScreenUpdating = True

    LR = ws.Range("A" & Rows.Count).End(xlUp).Row
    If LR > 1 Then
        If Not Evaluate("=ISREF('" & ldate & "'!A1)") Then
            Set wsnew = Worksheets.Add(After:=Worksheets(Worksheets.Count))
            wsnew.Name = ActiveSheet.Name = Format(dDate, "mmm-yy")
        Else
            Sheets(ldate).Move After:=Sheets(Sheets.Count)
            Sheets(ldate).Cells.Clear
        End If
        ws.Range("A2:BR" & LR).SpecialCells(xlCellTypeVisible).Copy
       
        wsnew.Range("A1").PasteSpecial xlPasteAll
        ws.Range("A1").AutoFilter Field:=1
        MyCount = MyCount + wsnew.Range("A" & Rows.Count).End(xlUp).Row - 1
        wsnew.Columns.AutoFit
    End If
Next i

 
Upvote 0
Hi, sorry that was a mistake in me putting the code in, changed it but it still errors, i think it might be because the FTdate is a mm-dd-yyyy.

Does this make sense?
 
Upvote 0

Forum statistics

Threads
1,215,648
Messages
6,126,007
Members
449,280
Latest member
Miahr

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