Moving location with the file open

PIsabel

Board Regular
Joined
Feb 4, 2014
Messages
121
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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Basically I just need the IF to work.


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

Forum statistics

Threads
1,215,418
Messages
6,124,793
Members
449,189
Latest member
kristinh

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