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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Basically I just need the IF to work.


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

Forum statistics

Threads
1,224,830
Messages
6,181,228
Members
453,025
Latest member
Hannah_Pham93

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