M
monika
hi...
I am writing a code using VBA....`Everytime i click the button its first
copies a worksheet from a workbook "X" to workbook "Y". Based on this
worksheet i make another 2 worksheets in workbook "Y". I want that when i
copy my worksheet...it should check whether the worksheet with a name "RAW"
already exits or not ... if exists then it should replace it. right now it
makes a copy by the name raw (2)???
here is my code for r that part:
BookPath = "G:\11 RFC\+06 FY 03_04\++04 Jan04\TCR\"
BookName = "abc_Jan04.xls"
OpenWorkBook
Sheets("Raw_Data").Select
Sheets("Raw_Data").Copy Before:=Workbooks("best.xls").Sheets(1)
filename = Dir("G:\11 RFC\+06 FY 03_04\++04 Jan04\TCR\abc_Jan04.xls")
....
..
Sub OpenWorkBook()
On Error Resume Next
Err.Clear
Windows(BookName).Activate
If Err.Number <> 0 Then
Err.Clear
Workbooks.Open filename:=BookPath & BookName
If Err.Number <> 0 Then
Err.Clear
MsgBox ("Unable to locate " & BookName)
End If
End If
pls suggest what change i need to do?
thanks
monika
I am writing a code using VBA....`Everytime i click the button its first
copies a worksheet from a workbook "X" to workbook "Y". Based on this
worksheet i make another 2 worksheets in workbook "Y". I want that when i
copy my worksheet...it should check whether the worksheet with a name "RAW"
already exits or not ... if exists then it should replace it. right now it
makes a copy by the name raw (2)???
here is my code for r that part:
BookPath = "G:\11 RFC\+06 FY 03_04\++04 Jan04\TCR\"
BookName = "abc_Jan04.xls"
OpenWorkBook
Sheets("Raw_Data").Select
Sheets("Raw_Data").Copy Before:=Workbooks("best.xls").Sheets(1)
filename = Dir("G:\11 RFC\+06 FY 03_04\++04 Jan04\TCR\abc_Jan04.xls")
....
..
Sub OpenWorkBook()
On Error Resume Next
Err.Clear
Windows(BookName).Activate
If Err.Number <> 0 Then
Err.Clear
Workbooks.Open filename:=BookPath & BookName
If Err.Number <> 0 Then
Err.Clear
MsgBox ("Unable to locate " & BookName)
End If
End If
pls suggest what change i need to do?
thanks
monika