Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50186

fixed date format in case computer has different date settings e.g dd/mm or mm/dd

$
0
0
Hi crew,

This is a simplified version

It finds the intersect of rCells row and Dcells column and places a value.

Have got this running beautifully on my machine! My date/time format is dd/mm/yy

However date/time formatting isn’t constant around the office and as Dcells value is a date it will error if the computers date/time format is in mm/dd/yy instead of dd/mm/yy

I tried formatting the cell in the code however it doesn’t seem to make a difference.

Any suggestions please so I can make this universal for all users?


13 Cashflow Matrix.xlsm

Extract of code

Code:

Sub GetAllAmount()

wsAll.Activate
     
  ' Application.ScreenUpdating = False
   
    Dim rCell As Range
    Dim dCell As Range

    For Each rCell In wsAll.Range("AllPortfolioCodes").Cells
    For Each dCell In wsAll.Range("EndDates").Cells
           
 '  Dim EndDate As String
 '  EndDate = Format(dCell.Value, "dd-mmm-yy")
   
 '  Dim StartDate As String
 '  StartDate = Format(dCell.Offset(-1, 0).Value, "dd-mmm-yy")
   
'-------FIND INTERSECT OF CELLS

                Dim HdrCol As Range
                Dim dCellDate As Date
                Dim SearchRange As Range
                Dim HdrRow As Range
                Dim FinDate As String
                dCellDate = Format(dCell.Value, "dd/mm/yy")
                   
                    FinDate = rCell.Value
                    'Find column ref
                        Set HdrCol = wsAll.Range("B2:M2").Find(dCellDate, lookat:=xlPart)
                        If Not HdrCol Is Nothing Then
                        End If
                    'Find row ref
                        Set SearchRange = wsAll.Range("A4:A20")
                        Set HdrRow = SearchRange.Find(rCell.Value, LookIn:=xlValues, lookat:=xlWhole)
                        Application.Goto Reference:=Cells(HdrRow.row, HdrCol.column)
                        ActiveCell.Value = "Worked"

   
   
Next dCell
   
Next rCell

Call GetIbbAmount

End Sub


Viewing all articles
Browse latest Browse all 50186

Trending Articles