Moving location with the file open

PIsabel

Board Regular
Joined
Feb 4, 2014
Messages
126
Office Version
  1. 365
Platform
  1. Windows
I have this code that with the open file renames the file then changes the folder and deletes the original file and it works fine.
Now I need the code to run differently depending on the location of the file.

For now I have this code but it is not working and I am not making it work


Someone help me?


Code:
Sub change_location()


    Dim strWbKill As String
    Dim wSheet As Worksheet
    
    
    Sheets("Orçamento").Select
    If ThisWorkbook.Path = "\\Servidor\servidor\ORÇAMENTOS\orç - A Fazer" Then
    With ThisWorkbook
        strWbKill = .FullName
        .SaveAs "\\Servidor\servidor\ORÇAMENTOS\orç - A Fazer\" & "Feito"
    End With
    Kill strWbKill
    End If


    Sheets("Orçamento").Select
    If ThisWorkbook.Path = "\\Servidor\servidor\ORÇAMENTOS\orç - Vendido" Then
    With ThisWorkbook
        strWbKill = .FullName
        .SaveAs "\\Servidor\servidor\ORÇAMENTOS\orç - Vendido\" & "Vendido"
    End With
    Kill strWbKill
    End If
    


End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Basically I just need the IF to work.


If ThisWorkbook.Path = "\\Servidor\servidor\ORÇAMENTOS\orç - Vendido" Then
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top