Sub kaffal()
Dim z As Long, e As Long, g As Long
Dim f As String, b As String
Sheets("Sheet1").Select
Cells(1, 1) = "=cell(""filename"")"
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
Cells(2, 1).Select
f = Dir(Cells(1, 2) & "*.xls")
Do While Len(f) > 0
ActiveCell.Formula = f
ActiveCell.Offset(1, 0).Select
f = Dir()
Loop
z = Cells(Rows.Count, 1).End(xlUp).Row
For e = 2 To z
If Cells(e, 1) <> ActiveWorkbook.Name Then
b = Cells(1, 2)
Name Cells(1, 2) & Cells(e, 1) As b
Cells(e, 2) = b
End If
Next e
MsgBox "Renaming is complete."
End Sub
Bookmarks