Get date format dd-mm-yyyy

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello JohnnyL
I need your help once again on the date format issue. I am getting the date format as mm/dd/yyyy in the destination sheet due to which the data is copied in the same wrong format to the connected sheets. I need your help once again to change the format to dd-mm-yyyy in the destination sheet which will automatically copy the same format to the other connected sheets.
2A date not able to edit.xlsm
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try this in the 'Match_Portal_Tally Subroutine

VBA Code:
    With wsDestination
'
        .Range("A2").Resize(UBound(OutputArray, 1), UBound(OutputArray, 2)) = OutputArray           ' Display results to DestinationSheet
        DestinationLastRow = .Range("A" & .Rows.Count).End(xlUp).Row                                ' Get last row used in column A of the destination sheeet
'
        .Range("B2:M" & DestinationLastRow).Interior.Color = RGB(146, 208, 80)                      ' Highlight the range green
        .Range("B2:M" & DestinationLastRow).Font.Bold = True                                        ' Make the range Bold
'
        For SheetRow = 2 To DestinationLastRow                                                      ' Loop through rows of the destination sheet
            .Range("F" & SheetRow).Value2 = DateValue(.Range("F" & SheetRow))                       '   Write the Serial Date to the cell
            .Range("M" & SheetRow).Value2 = DateValue(.Range("M" & SheetRow))                       '   Write the Serial Date to the cell
        Next
'
        .Range("F:F").NumberFormat = "dd-mm-yyyy"                                                   ' Format the date the way we want it to appear
        
        .Range("M:M").NumberFormat = "dd-mm-yyyy"                                                   ' Format the date the way we want it to appear
'
        .Range("N2:N" & DestinationLastRow).Formula = "=$C$1 & "" "" & C2" & _
                " & ""  "" & $D$1 & "" "" & D2 & ""  "" & $E$1 & "" "" & E2" & _
                " & ""  "" & $F$1 & "" "" & F2 & ""  "" & $K$1" & _
                " & "" "" & K2 & ""  "" & $M$1 & "" "" & TEXT(M2,""DD-MM-YYYY"")"                   ' Copy Narration Formula to Column N
'
        .Range("N2:N" & DestinationLastRow).Copy                                                    ' Copy formula range into memory
        .Range("N2:N" & DestinationLastRow).PasteSpecial xlPasteValues                              ' Paste just the vales back to range
        Application.CutCopyMode = False                                                             ' Clear clipboard & 'marching ants' around copied range
    End With

I altered 1 line in that.
 
Upvote 0
Solution
Perfect.👌👌
I have been trying to edit and correct it since morning. Which line did you exactly edit or add....
 
Upvote 0
.Range("F" & SheetRow).Value2 = DateValue(.Range("F" & SheetRow)) ' Write the Serial Date to the cell

It was
.Range("F" & SheetRow).Value = .Range("F" & SheetRow).Text ' Write the TextDate to the cell
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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