Solved

Macro semi-working

Posted on 2013-12-23
4
163 Views
Last Modified: 2013-12-27
Hi Guys, I have a Macro which cuts and pastes a series of text files from 1 folder to another. Wierdly, only have of them work from this code:

Sub CallMoveFiles()
Dim Prevday As String

      Prevday = WorksheetFunction.WorkDay(Date, -1)
   Prevday = Format(Prevday, "DDMMYY")

 MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", _
 "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, _
 "StructNotesBSRec_Daily" & "*.txt"""
   
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "ALMBSRec_Daily" & "*.txt"""
   
   
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "CorpBankingBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "GIBSRec_Daily" & "*.txt"""
   
    MoveFiles "v\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "GSSBSRec_Daily" & "*.txt"""
    MoveFiles "v\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "Murex3BSRec_Daily" & "*.txt"""
   
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "WSSBSRec_Daily" & "*.txt"""
     MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "SophisBSRec_Daily" & "*.txt"""
     MoveFiles "v\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "CreditBSRec_Daily" & "*.txt"""
   
    MoveFiles "v\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "RatesBSRec_Daily" & "*.txt"""
   
   

The ones that don't move I have attached to see if anyone can work it out?
CreditBSRec-Daily-20131220-12153.txt
0
Comment
Question by:Justincut
  • 2
4 Comments
 
LVL 4

Expert Comment

by:andrew_man
ID: 39736035
some typo here!
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39736684
The code is not formatted correctly:

"v\Treasury Finance Controls"

should be

"v:\Treasury Finance Controls"

There are some other errors as well.
0
 

Author Comment

by:Justincut
ID: 39736740
Cheers! What other errors are there?
0
 
LVL 18

Accepted Solution

by:
Steven Harris earned 500 total points
ID: 39736763
When your code is copy/pasted to VBA, there are line breaks that shouldn't be there.  Try using this version:

Sub CallMoveFiles()
Dim Prevday As String
Prevday = WorksheetFunction.WorkDay(Date, -1)
Prevday = Format(Prevday, "DDMMYY")

    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "StructNotesBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "ALMBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "CorpBankingBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "GIBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "GSSBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "Murex3BSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "WSSBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "SophisBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "CreditBSRec_Daily" & "*.txt"""
    MoveFiles "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS", "v:\Treasury Finance Controls\Ledger v SS Recs\EOD Recs\BS\2013\12_2013\" & Prevday, "RatesBSRec_Daily" & "*.txt"""

End Sub

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question