VBA: Not quite working

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
780
My coding is going to Call Forecast_Day_3 when I want it once it has tested the file is there (which it is), to go to Else...Any ideas what is wrong here?

Many thanks.

Code:
Sub Forecast_Day_2()


    Dim destcell As Range, r As Long
    Dim fileSpec As String, folderPath As String, fileName As String
    Dim FilePath As String
    Dim TestStr As String


    cellvalue2 = Workbooks("Forecast Template.xlsx").Sheets("Revenue").Range("U12")
    dow2 = Workbooks("Forecast Template.xlsx").Sheets("Revenue").Range("V12")
    
    myvalue3 = 1802
    
    FilePath = FD & "Revenue\" & myvalue3 & "\" & cellvalue2
    
    TestStr = ""
    On Error Resume Next
    TestStr = Dir(FilePath)
    On Error GoTo 0
    If TestStr = "" Then
    Call Forecast_Day_3
    Else
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,318
Office Version
  1. 365
Platform
  1. Windows
Your code will only call Forecast_Day_3 if the file does not exist, is that what you want to happen?
 

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
780
Yes, that is right, it doesn't seem to be finding that the file exists in that folder - which it does.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,318
Office Version
  1. 365
Platform
  1. Windows
Have you checked the value of FilePath?

By the way, where is FD declared/given a value?
 

Forum statistics

Threads
1,148,291
Messages
5,745,892
Members
423,983
Latest member
blackworx

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
Top