hello I need combining two codes in one
when I open inputbox I will writing name file then when create the file should filter data without implement in open file , the open file should keeping the orginal data without any changes . the changes just in new file .which creat by inputbox .
I try this
Sub test()
Dim wb As Object
Application.ScreenUpdating = False
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
TryAgain:
Flname = InputBox("Enter File Name :", "Creating New File...")
If Flname <> "" Then
Set wb = Workbooks.Add
wb.Sheets(1).Name = "sheet1"
wb.Sheets(1).Cells(1).CurrentRegion.Clear
With ThisWorkbook.ActiveSheet.Cells(1).CurrentRegion
Dim LR As Long
LR = .Range("H" & Rows.Count).End(xlUp).Row
.AutoFilterMode = False
.Range("m2:m" & LR).Formula = "=or(n(j2)<>0,n(k2)<>0)"
With .Range("H1:M" & LR)
.AutoFilter Field:=6, Criteria1:=False
If .Columns(1).SpecialCells(12).Count > 1 Then
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
.Columns(.Columns.Count).Clear
End With
End With
wb.SaveAs ThisWorkbook.Path & "\" & Flname, FileFormat:=51
If Err.Number = 1004 Then
wb.Close
MsgBox "File Name Not Valid" & vbCrLf & vbCrLf & "Try Again."
GoTo TryAgain
End If
ActiveWorkbook.Close
Application.ScreenUpdating = True
I hope somebody help .