Solved

Macro semi-working

Posted on 2013-12-23
4
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

738 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