VBA: Not quite working

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
834
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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Your code will only call Forecast_Day_3 if the file does not exist, is that what you want to happen?
 
Upvote 0
Yes, that is right, it doesn't seem to be finding that the file exists in that folder - which it does.
 
Upvote 0
Have you checked the value of FilePath?

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

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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