Can anyone help me write a code about coping data from many files and paste them to one file !?

Hello ! 
As I said in title , I have alot files (e.g. 60 files) and I want to write a code to copy 5 columns (for examples) of special sheet of files and paste them in one file respectively. For perceive it I explained it more below .
Suppose one of my files is simplified as this : http://s000.tinyupload.com/?file_id=00699705919876414523
The name of  this file is 2006Oct and assume my excel files are like "2006Oct, 2006Nov,2006Dec,2007Jan ... 2010Dec". At first I should go to "my files" sheet of 2006Oct file and copy columns " A,B,C,D,E,F " that has "PerturbationNumber=1"
respectively and then paste these to a file that is output file and repeat this process for the other files ( 2006Nov and etc ) and paste data in output file sequentially. 
I appreciate and look foreward for any help in this issue.
Majid

Try code below
Sub CombineBooks()
Dim wb As Workbook
Dim sourceSht As Worksheet
Dim destSht As Worksheet
Set destSht = ThisWorkbook.Sheets(1)
destSht.Cells.Clear
FolderName = "C:\temp\test\"
file = Dir(FolderName & "*.xlsx")
firstSht = True
Do While file <> ""
Set wb = Workbooks.Open(Filename:=FolderName & file, ReadOnly:=True)
Set sourceSht = wb.Sheets(1)
With sourceSht
sourceLastRow = .Range("A" & Rows.Count).End(xlUp).Row
If .Cells.AutoFilter Then
.Cells.AutoFilter 'turn off autofilter
End If
.Cells.AutoFilter Field:=6, Criteria1:="1"
If firstSht = True Then
Set copyRange = .Range("A1", .Range("E" & sourceLastRow)).SpecialCells(xlCellTypeVisible)
destSht.Range("F1") = "FileName"
firstSht = False
destNewRow = 1
Else
Set copyRange = .Range("A2", .Range("E" & sourceLastRow)).SpecialCells(xlCellTypeVisible)
destNewRow = destSht.Range("A" & Rows.Count).End(xlUp).Row + 1
End If
copyRange.Copy Destination:=destSht.Range("A" & destNewRow)
LastRow = destSht.Range("A" & Rows.Count).End(xlUp).Row
If destNewRow = 1 Then
destSht.Range("F2:F" & LastRow) = file
Else
destSht.Range("F" & destNewRow & ":F" & LastRow) = file
End If
End With
wb.Close savechanges:=False
file = Dir()
Loop
End Sub
jdweng

Similar Messages

  • Can Anyone help I have a question about ordering items from iphoto

    HI,
    My question is .... Ive just moved from Australia to London & I am unable to order items Ive made in iphoto & have them sent to London.
    Previousely ,living in AustraliaI had no problem & Ive ordered items from iphoto that Ive created here in Lonond & had them sent back to Australia no problem.
    But I just cannot create here in London & then have them sent here,even if I change the credit card details ....
    Does anyone know how to tackle this ?
    Regards
    Lyndajane28

    Thank you LarryHN, you are a superstar... Ive been struggling with this for  a while now & you have solved my problem ..Thank you Thank you Thank you
    Regards
    Lyndajane28

  • Can anyone help me wid d codes for  Generated Program for gate pass

    can anyone help me wid d codes for  Generated Program for gate pass in MM
    Message was edited by:
            Ronei Shedi

    Hi
    There is no std business process in SAP for Gate pass for the Material entry
    before GR stock entry into the stores.
    You have to write a Z program based on the details of Purchase order tables EKKO and EKPO.
    This will mainly check whether the correct PO qty was delivered or not with proper quality.
    So use the PO tables EKKO and EKPO and fetch the data and use it
    Since this is client specific there is no feneralised program for it.
    Reward points if useful
    Regards
    Anji

  • Can anyone help me write a script that would click "get info" and then "enter" on each movie in my itunes library? I am asking because my itunes 11 repeatedly loses the artwork to my movies in my itunes library.

    Can anyone help me write a script that would click "get info" and then "enter" on each movie in my itunes library? I am asking because my itunes 11 repeatedly loses the artwork to my movies in my itunes library. I can restore the artwork (and make my apple tv see the movie exists as well) by going into the movie library and clicking on each movie by hand, slecting get info, and then selecting enter. Now doing this 10 times in 20 days was fun and all BUT I would really like to automate the process so everytime itunes screws it up I can fix it easier.
    I saw this example of an itunes script that restores artwork for music
    tell application "iTunes" set theSelection to selection repeat with i from 1 to count of theSelection tell (item i of theSelection) set artworkCount to count of artwork repeat artworkCount times set theArtwork to data of artwork 1 delete artwork 1 set data of artwork artworkCount to theArtwork end repeat end tell end repeat end tell
    but I need to tweak this to fit my needs for simply clicking the "get info" button and "enter" in the movie library rather than all the stuff this guy has listed. Any ideas or help on writing this? Thanks.

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • I am not able to see the airplay icon with Maverick. Can anyone help on how to go about this?

    I am not able to see the airplay icon with Maverick. Can anyone help on how to go about this?

    Does restarting the router help?
    Best.

  • HT1766 sorry can anyone help me...? my iphone is not starting and when i want to start it after the apple icon it appear that connect to itunes and when i connect it just there is one option and it says that restore your iphone.when i restore it says cant

    sorry can anyone help me...? my iphone is not starting and when i want to start it after the apple icon it appear that connect to itunes and when i connect it just there is one option and it says that restore your iphone.when i restore it says cant restore... please help me...

    See Here...
    iOS: Not responding or does not turn on
    Try this First...
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear...
    Usually takes about 15 - 20 Seconds... ( But can take Longer...)
    Release the Buttons...
    http://support.apple.com/kb/ht1430

  • Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.

    Before I go into a lengthy explanation of the problem: Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.
    Thanks much.
    Emile

    Choose Force Quit from the Apple menu and close Mail from there.
    (103661)

  • Can anyone help I want to remove the voice alert from icalendar in Mac Pro?

    Can anyone help I want to remove the voice alert from icalendar in Mac Pro?

    Please post a screenshot of the Dictation & Speech preference pane with the Text to Speech tab selected.
    Start a reply to this message. Click the camera icon in the toolbar of the editing window and select the image file to upload it. You can also include text in the reply.

  • I can't transfer music and other files from library to my iphone 4 by dragging it.can anyone help me?is there any other way to transfer files into iphone?

    i can't transfer music and other files from library to my iphone 4 by dragging it.can anyone help me?is there any other way to transfer files into iphone?

    If you want to drag and drop ( don;t know why you would do this), you will have to check manually manage music.
    Why not just sync?
    iPhone User Guide (For iOS 5.0 Software)

  • Can anyone help with an Error Code 4450

    I keep trying to burn cd's and everytime that I do, itunes cancels the disk burn and gives me the error code 4450. can anyone help out with this? thanks..

    I am having the exact same problem! and now i can't access my pending downloads!! if anybody has any answers, i am begging you, please help me. if i can't fix this then i have wasted $40., so please, help me!

  • Picking problem.Can anyone help me debug my code?

    Can someone help me debug my code?
    I try to pick a ColorCube,
    but when I pick a ColorCube in my scene,
    I get the following error message:
    Exception occurred during Behavior execution:
    javax.media.j3d.CapabilityNotSetException: GeometryArray: no capability to get v
    ertex count
    at javax.media.j3d.GeometryArray.getVertexCount(GeometryArray.java:581)
    at com.sun.j3d.utils.picking.PickResult.intersect(PickResult.java:654)
    at com.sun.j3d.utils.picking.PickResult.generateIntersections(PickResult
    .java:635)
    at com.sun.j3d.utils.picking.PickResult.numIntersections(PickResult.java
    :422)
    at com.sun.j3d.utils.picking.PickTool.pickGeomAllSortedIntersect(PickToo
    l.java:854)
    at com.sun.j3d.utils.picking.PickTool.pickGeomClosestIntersect(PickTool.
    java:915)
    at com.sun.j3d.utils.picking.PickTool.pickClosest(PickTool.java:566)
    at SimpleBehaviorApp$SimpleBehavior.processStimulus(SimpleBehaviorApp.ja
    va:119)
    at javax.media.j3d.BehaviorScheduler.doWork(BehaviorScheduler.java:172)
    at javax.media.j3d.J3dThread.run(J3dThread.java:250)
    when i try to run the following code:
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.geometry.ColorCube;
    import com.sun.j3d.utils.picking.*;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import javax.swing.JOptionPane;
    import java.awt.event.*;
    import java.util.Enumeration;
    // SimpleBehaviorApp renders a single ColorCube
    // that rotates when any key is pressed.
    public class SimpleBehaviorApp extends Applet
    BranchGroup objRoot;
    Canvas3D canvas3D;
    public SimpleBehaviorApp()
    setLayout(new BorderLayout());
    GraphicsConfiguration config =
    SimpleUniverse.getPreferredConfiguration();
    canvas3D = new Canvas3D(config);
    add("Center", canvas3D);
    BranchGroup scene = createSceneGraph();
    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(scene);
    } // end of SimpleBehaviorApp (constructor)
    public BranchGroup createSceneGraph()
    // Create the root of the branch graph
    objRoot = new BranchGroup();
    objRoot.setCapability(BranchGroup.ALLOW_PICKABLE_READ);
    objRoot.setCapability(BranchGroup.ALLOW_PICKABLE_WRITE);
    objRoot.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
    objRoot.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
    objRoot.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
    ColorCube ca=new ColorCube(0.4);
    ca.setCapability(ColorCube.ALLOW_PICKABLE_READ);
    ca.setCapability(ColorCube.ALLOW_PICKABLE_WRITE);
    ca.setCapability(ColorCube.ALLOW_GEOMETRY_READ);
    ca.setCapability(ColorCube.ALLOW_GEOMETRY_WRITE);
    ca.setCapability(ColorCube.ENABLE_PICK_REPORTING);
    ca.setCapability(ColorCube.ALLOW_BOUNDS_READ);
    ca.setCapability(ColorCube.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
    ca.setPickable(true);
    objRoot.addChild(ca);
    SimpleBehavior myRotationBehavior = new SimpleBehavior(objRoot,canvas3D);
    myRotationBehavior.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myRotationBehavior);
    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();
    return objRoot;
    } // end of CreateSceneGraph method of SimpleBehaviorApp
    //�������OSimpleBehavior�����@���������������u��
    public class SimpleBehavior extends Behavior
    private TransformGroup targetTG;
    private Transform3D rotation = new Transform3D();
    private WakeupCondition wCond;
    private PickCanvas pickCanvas;
    // create SimpleBehavior
    public SimpleBehavior(BranchGroup targetBG,Canvas3D canvas3D)
    wCond=new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
    pickCanvas=new PickCanvas(canvas3D,targetBG);
    pickCanvas.setTolerance(5.0f);
    pickCanvas.setMode(PickCanvas.GEOMETRY_INTERSECT_INFO);
    public void initialize()
    // set initial wakeup condition
    this.setSchedulingBounds(new BoundingSphere(new Point3d(),300));
    this.wakeupOn(wCond);
    public void processStimulus(Enumeration criteria)
    PickResult pickResult;
    MouseEvent event=(MouseEvent)((WakeupOnAWTEvent) criteria.nextElement()).getAWTEvent()[0];
    pickCanvas.setShapeLocation(event);
    Point3d eyePos=pickCanvas.getStartPosition();
    if(pickCanvas.pickClosest()!=null)
    pickResult=pickCanvas.pickClosest();
    Node node=pickResult.getObject();
    PickTool.setCapabilities(node,PickTool.INTERSECT_FULL);
    else
    JOptionPane.showMessageDialog(null,"pickCanvas.pickClosest()������");
    this.wakeupOn(wCond);
    } // end of class SimpleBehavior
    public static void main(String[] args)
    Frame frame = new MainFrame(new SimpleBehaviorApp(), 256, 256);
    } // end of main (method of SimpleBehaviorApp)
    } // end of class SimpleBehaviorApp

    Hi Tinyuh,
    ColorCube?? I learnt thru mistakes. YEPThe following code creates a pickable colorcube.. it works for me!
         public BranchGroup addObject(Vector3d vector)
              BranchGroup branch = new BranchGroup();
              branch.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
              branch.setCapability(BranchGroup.ALLOW_DETACH);
              TransformGroup trans = new TransformGroup();
              trans.setBounds(new BoundingSphere());
              Transform3D t3d = new Transform3D();
              t3d.setTranslation(vector);
              trans.setTransform(t3d);
              branch.addChild(trans);
              ColorCube cube = new ColorCube(0.5d);
              cube.setCollidable(true);
              cube.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
              cube.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
                    cube.setCapability(Shape3D.ALLOW_COLLIDABLE_READ);
              cube.setPickable(true);
              trans.addChild(cube);
              return branch;

  • Can anyone help me!!! i have an i pod touch and the 4 digit passcode has been forgotten. i have tried a number of times to restore the factory settings on i tunes and have put the i pod into recovery mode, but attempts keep timing out

    my son has forgotten his 4 digit pass code for hios i pod touch. i have been instructed to disable it and connect to i tunes to restore factory settings. when I do this the download time is anything up to 20 hours and it keeps timing out. it is now saying that i tunes cannot connect to the i pod because it is locked with a passcode and saying that i must enter the passcode - can anyone help?

    - To get around the passcode issue, place the iPod in recovery mode. For how to see:
    iPhone and iPod touch: Unable to update or restore
    - If you are getting a network timeout error during the restore, disable the computer's security software during the restore.

  • Hi, can anyone help me because I've been trying to download the iTunes and everytime I am installing it its says --- An error occured during the installation of assembly Microsoft.VC80.CRT,type,="win32",version,="8.0.50727.6195...etc..

    Hi, can anyone help me because I've been trying to download the iTunes on my PC ( windows vista ) and everytime I am installing it its says --- An error occured during the installation of assembly Microsoft.VC80.CRT,type,="win32",version,="8.0.50727.6195...etc..Thank you.

    it says that Windows Resource Protection could not start the repair service.
    Okay. We've got a broken Windows Modules Installer on the PC, then.
    It's a bit of an involved fix getting past it, but we've had success here with it in the past.
    First, I'd strongly suggest setting up a system restore point.
    Now try the Scenario III treatment from the following document:
    Windows Update Error 80070424 in Vista
    Head back into Windows Update and attempt to get updates again. If they still fail, this time with an 8000FFFF error code, try the following Microsoft document:
    Windows Update error 8000FFFF
    If you get Windows Updates flowing again, stock up on any you're behind on (restarting the PC when requested to do so). This may take some time and may have to be done in several batches, depending on how far you've fallen behind. Basically, keep going back to Windows Update until it stops offering you new updates.
    After the updates have been installed, restart the PC one more time (in order to ensure that any pending installs requiring a restart have been resolved).
    Now try another iTunes install. Does it go through without the 0x80070424 this time?

  • My mum set my itunes account up a few years back and she cant remember the password for my email or the security questions can anyone help as i  ow have an ipad mini from ipod i changed over my settings bought a top up and can not purchase any thing

    my mum set up an account for itunes a few years ago but she cant remember the question recovery answers can anyone help as i can not purchase anything 

    Forgotten Security Questions / Answers...
    See Here > Apple ID: Contacting Apple for help with Apple ID account security
              Ask to speak with the Account Security Team...
    Or Email Here  >  Apple  Support  iTunes Store  Contact
    More Info >  Apple ID: All about Apple ID security questions
    Note:
    You can only set up and/or change a Rescue Email Before you forget the questions/answers.

  • Can anyone help with the installation of Premiere Elements 10 from disk onto a Mac?

    I have tried to install to a Mac from DVD. The installation fails at 51% on Disc 3 (the first disc for Mac) and returns Error 7. I have tried to download a trial version, but it is no longer available for PE 10. I've also tried to run the Premiere Elements 10 Installation Fix, but it won't run, returning an error that says the Certificate has been revoked. Can anyone help?

    Adobe - Lightroom : For Macintosh
    Hal

Maybe you are looking for

  • Rich Client advice

    Hi all, Been searching the archives. I've developed a Swing standalone app and would like to convert it into a "Rick Client" but shifting certain parts over to a backend. My initial work has been a servlet on Tomcat webserver I maintain. Can anyone p

  • Bizarre problem JDBC/SDO_UNION on insert

    Hi, I've got a case where I am trying to do an SDO_UNION on two shapes and use the result as part of an INSERT statement. Note that I am doing this through JDBC calls out of Java. Unfortunately, I am encountering a bizarre problem... when I call the

  • Need Chief of Organization as Possible Agent

    Hi, I have a workflow task that that is an approval step of a workflow that only managers should perform. In the agent determination for the workflow I have a rule that I can use to determine the correct responsible agent who needs to approve this st

  • Strange Oracle Behaviour - only month end or high load periods

    Hi SAP Gurus In one of our systems I am expreriencing a strange behaviour from Oracle, in that it seems to be in reconnect, but yet it is not, it resets and carries on but do produce Dump and SM21 log messages, the dump is not really helpfull as it i

  • Flash player keeps crashing when i watch a video online

    flash player keeps crashing when i watch a video online