Sameer.k21
Member
Hi All,
I am trying unmerge, delete filter and copy the data to another workbook. however I get this error. Please advice.
I am trying unmerge, delete filter and copy the data to another workbook. however I get this error. Please advice.
Code:
Sub rawdata()
Dim lngStart As Long, lngEnd As Long
Dim lrow As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheet2.Activate
Columns("A:F").Select
Selection.UnMerge
Range("C:C,F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.NumberFormat = "[$-10409]m/d/yyyy"
Sheet1.Activate
lngStart = Range("C7").Value 'assume this is the start date
lngEnd = Range("E7").Value 'assume this is the end date
Sheet2.Activate
Range("E:E").AutoFilter Field:=1, Criteria1:=">=" & lngStart, Operator:=xlAnd, Criteria2:="<=" & lngEnd
lrow = 2
With Sheet2.Cells(2, 1).CurrentRegion
.Offset(1).Resize(.Rows.Count).Copy
Workbooks("Data File.xls").Activate
ThisWorkbook.Sheets(1).Cells(lrow, 2).PasteSpecial xlPasteValues
Application.CutCopyMode = False: lrow .Rows.Count - 1
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub