onyourmark
asked on
reference current directory
Hello. I kindly received the macro below. I would like to change it so that it references the current directory where the starting file is located. This macro creates a bunch of new files based on the starting file and I want them all to be in the same directory as the starting file, instead of hard coding a directory in the macro. Can anyone suggest the solution to this?
The directory is currently hard coded as
"C:\Users\Bill\Desktop\Ana lysis\n-1A ttrSelOneR \
Thank you.
The directory is currently hard coded as
"C:\Users\Bill\Desktop\Ana
Thank you.
Sub decrementrows()
Application.DisplayAlerts = False
lastrow = Range("A" & Rows.Count).End(xlUp).Row
For I = lastrow To lastrow - 158 Step -1
Cells(I, 1).EntireRow.Delete
fname = "C:\Users\Bill\Desktop\Sony Analysis\n-1AttrSelOneR\StartingFile -" & lastrow - I + 1 & ".csv"
ActiveWorkbook.SaveAs Filename:=fname, FileFormat:=xlCSV
Next I
Application.DisplayAlerts = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER