Hello,
I wrote this code to look in a folder for a workbook and move it to another folder. The name of the folder and workbooks are based on cell values found in another workbook. I think I have everything right but the code can't find the first folder. Please look at the section that is referring to a cell location for the folder locations. I believe the issue is with the references "cellvalue3" and "cellValue2". The code right below are supposed to insert a slash after each reference but I don't think its working.
I wrote this code to look in a folder for a workbook and move it to another folder. The name of the folder and workbooks are based on cell values found in another workbook. I think I have everything right but the code can't find the first folder. Please look at the section that is referring to a cell location for the folder locations. I believe the issue is with the references "cellvalue3" and "cellValue2". The code right below are supposed to insert a slash after each reference but I don't think its working.
Code:
Sub Copy_One_File()
'Below sets a WORRKBOOK reference to ("6251 Vivint Rental Report.xlsm") workbook.
Dim folderName As String
Dim folderName2 As String
Dim src As Workbook
Set src = Workbooks("313670 Avanir Biweekly Dashboard Report.xlsm")
'Below set a CELL reference to the("313670 Avanir Biweekly Dashboard Report.xlsm") workbook.
'The numbers below refer to row number and column number respectivly. (33, 4) 33= row, 4 = column.
Dim cellValue As String
Dim cellValue2 As String
Dim cellValue3 As String
cellValue = src.Worksheets("Data").Cells(176, 1)
cellValue2 = src.Worksheets("Data").Cells(168, 1)
cellValue3 = src.Worksheets("Data").Cells(176, 2)
'Below is the original location of the workbook. This locatin is where it will be moved from.
folderName = "\\fleet.ad\data\Data1\VMSSHARE\FS\FPSCOEASSO\Temporary Fleet Reports\313670 Avanir\Report Depository\" & cellValue
'**************I THINK THIS IS THE TROUBLE AREA************************************
'Below is where the workbook will be moved to.
folderName2 = "\\fleet.ad\data\Data1\VMSSHARE\FS\FPSCOEASSO\Temporary Fleet Reports\313670 Avanir\" & cellValue3 & cellValue2 & cellValue
'Below adds a backslash to the end of code above to locate the folder.
If Right(cellValue3, 1) <> "\" Then
cellValue3 = cellValue3 & "\"
End If
If Right(cellValue2, 1) <> "\" Then
cellValue2 = cellValue2 & "\"
End If
'*************************************************************************************
'Below says look at reference "folderName" and move workbook to reference "folderName2". This moves the workbooks to different folders.
Name folderName As folderName2
End Sub