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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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