jleve1974
01-30-2008, 01:14 PM
The code below basically just removes column A from all files within directory "C:\Documents and Settings\levanoj\Desktop\Lab1".
Can anyone adjust the code to instead prompt me to select a directory instead of just running it from the one noted?
Sub RemoveColumnA()
Dim myDir As String, fn As String
myDir = "C:\Documents and Settings\levanoj\Desktop\Lab 1"
fn = Dir(myDir & "\*.xls")
Do While fn <> ""
On Error Resume Next
With Workbooks.Open(myDir & "\" & fn)
.Sheets("Sheet1").Columns("a").Delete
.Close True
End With
fn = Dir()
Loop
MsgBox "Done!"
End Sub
Can anyone adjust the code to instead prompt me to select a directory instead of just running it from the one noted?
Sub RemoveColumnA()
Dim myDir As String, fn As String
myDir = "C:\Documents and Settings\levanoj\Desktop\Lab 1"
fn = Dir(myDir & "\*.xls")
Do While fn <> ""
On Error Resume Next
With Workbooks.Open(myDir & "\" & fn)
.Sheets("Sheet1").Columns("a").Delete
.Close True
End With
fn = Dir()
Loop
MsgBox "Done!"
End Sub