Hi..thanks for reply....
code is fine but unable to get file name....i want to check file is exists in any one folder if exists then get last two character of file name.
Sub file_prepare()
Dim s1, s2 As String
Dim count1, count2 As String
Dim date1, fileno As String
Dim dir1, dirchngpath1, dir2, dirchngpath2, fileno1 As String
dirchngpath1 = ("C:\Users\nk\Desktop\Data Sync\")
ChDir (dirchngpath1)
dir1 = Dir(dirchngpath1 & "Data_Sounth_" & Format(Date, "DDMMYYYY") & "_ *.xlsx")
s1 = dir1
dirchngpath2 = ("D:\Data_Nk\Sync Data\Data\")
ChDir (dirchngpath2)
dir2 = Dir(dirchngpath2 & "Data_Sounth_" & Format(Date, "DDMMYYYY") & "_ * _" & fileno & ".xlsx")
s2 = dir2
If Dir(s1) <>"" And Dir(s2) <> "" Then
fileno1 = Right(s1, 2) +1
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:="C:\Users\nk\Desktop\Data Sync\Data_Sounth_" & Format(Date, "DDMMYYYY") & "_" & count2 & "_" & fileno1 & ".xlsx" ', FileType:=xlWorkbookNormal
ActiveWorkbook.Close
Else
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:="C:\Users\nk\Desktop\Data Sync\Data_Sounth_" & Format(Date, "DDMMYYYY") & "_" & count2 & "_" & fileno & ".xlsx" ', FileType:=xlWorkbookNormal
ActiveWorkbook.Close
end if
end sub