narsing rao
Member
i have small problem with workbook "data_base" ...after copying the data to another sheet the formula in column "D" should show
like this below
but its showing as below
and i am not getting the proper results ...can you please let me know how to avoid it. code line below
what ever the comments i have tried all methods but non worked.
like this below
Code:
"=IF([@[Time Out]]="","",([Time Out]-[Time In])*24)"
Code:
"=IF(TTM_Form.xlsm!Table2[@[Time Out]]="","",(TTM_Form.xlsm!Table2[Time Out]-TTM_Form.xlsm!Table2[Time In])*24)"
what ever the comments i have tried all methods but non worked.
Code:
Option Explicit
Sub DataBasedOnDate1()
Dim wbSource As Workbook, wbDestination As Workbook
Dim startDate As Date, Enddate As Date, dtTodayDate As String
Dim Source As Worksheet, Destination As Worksheet
Dim lRow As Long, nRow As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
startDate = Sheets("workform").Range("D6").Value
Enddate = Sheets("workform").Range("D7").Value
dtTodayDate = Format(Date, "mmm-dd-yyyy")
Set wbDestination = Workbooks("Data_Base.xlsm")
Set Destination = wbDestination.Sheets("Logintime")
Set wbSource = Workbooks.Open("D:\TMS_Project\TTM_Form.xlsm")
Set Source = wbSource.Sheets("Data Sheet")
With Destination
.UsedRange.Clear
End With
With Source
.AutoFilterMode = False
lRow = .Cells(Rows.Count, "C").End(xlUp).Row
With .Range("B2:F" & lRow)
.AutoFilter Field:=5, Criteria1:=">=" & CDbl(startDate), Operator:=xlAnd, Criteria2:="<=" & CDbl(Enddate)
'Destination.Range("A1").Formula = Source.Range("F1").Formula
.SpecialCells(xlCellTypeVisible).Copy Destination:=Destination.Range("A1")
'wbDestination.Sheets("Logintime").Range("D2").Value = .Range("D2").End(xlDown).Offset(0, 41).Value
'.SpecialCells(xlCellTypeVisible).Copy
'Destination.Range("A1").PasteSpecial xlPasteFormulas
wbDestination.Sheets("Logintime").Columns(5).EntireColumn.Delete
wbDestination.Sheets("Logintime").Range("A:D").Rows.AutoFit
Dim Lastrow As Long
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
'wbDestination.Sheets("Logintime").Range("D2:D").Formula = "=TEXT(C2-B2,""hh:mm"")"
wbDestination.Sheets("Logintime").Activate
wbDestination.Save
wbSource.Close
End With
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub