Dear All,
I need your help. I need to write a macro in the [Sub Workbook_Open()] with if statement stating that if this file opened from folder (C:/Test), then do this.
If the file opened from other folder, don't do any thing
Thank you very much
Dear All,
I need your help. I need to write a macro in the [Sub Workbook_Open()] with if statement stating that if this file opened from folder (C:/Test), then do this.
If the file opened from other folder, don't do any thing
Thank you very much
can you explain better your goal ?
Say there is file (called love.xlsm) saved in folder c:/teat. The same file open (love.xlsm) copied to another folder. So if the file love.xlsm opened from folder c:/test, run macro (say clear cell A1 text). but if opened from another folder don't clear A1 text
If lCase(ThisWorkbook.Path) = "c:\test" then ...
Sorry it is not working for any of bellow. I did the following:
orPrivate Sub Workbook_Open() If LCase(ThisWorkbook.Path) = "C:\Test" Then Sheets("Sheet1").Select Selection.ClearContents Else Exit Sub End If End Sub
Private Sub Workbook_Open() If ThisWorkbook.Path = "C:\Test" Then Sheets("Sheet1").Select Selection.ClearContents Else Exit Sub End If End Sub
Last edited by loveguy1977; 09-04-2013 at 12:50 PM.
Sorry guys
I found my mistake
it should be like this
Private Sub Workbook_Open() If ThisWorkbook.Path = "C:\Test" Then Sheets("Sheet1").Select Range("A1").Select Selection.ClearContents End If End Sub
Private Sub Workbook_Open() If ThisWorkbook.Path = "C:\Test" Then Sheets("Sheet1").Range("A1").ClearContents End Sub