Results 1 to 7 of 7

Thread: code it better...

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2010
    Posts
    7

    code it better...

    as i am a newbie to that field, i have the following code.

    I would like to make it shorter and better.

    Note that this code copies some cells from one worksheet to another worksheet, only at the last row that is empty.

    this code must be repeated for 20 or more times. Range(*90) shows the place for the data for MIG. The range 89 show the place for ATE.

    Finally, at the final code "BBB" will become "ccc", "DDD", for each type e.g bbb--> Mig, CCC-->ATE etc. Thats it.

    so i am confused with ifs and thens, i tried to make something but not work (obviously). Therefore, i need your help!




    Code:
      Workbooks.Open Filename:="D:\MARFIN\VASIKA ARXEIA\NAFTEMPORIKI.xls"
    
        
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("O90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("c65536").End(xlUp).Offset(1, 0).PasteSpecial
        
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("K90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("D65536").End(xlUp).Offset(1, 0).PasteSpecial
    
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("L90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("E65536").End(xlUp).Offset(1, 0).PasteSpecial
            
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("M90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("F65536").End(xlUp).Offset(1, 0).PasteSpecial
    
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("C90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("G5536").End(xlUp).Offset(1, 0).PasteSpecial
    
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("AAA").Select
        Range("N90").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("H5536").End(xlUp).Offset(1, 0).PasteSpecial
        
        Windows("NAFTEMPORIKI.xls").Activate
        Sheets("BBB").Select
        Range("H212").Select
        Selection.Copy
        Windows("OLA 20.xlsx").Activate
        Sheets("MIG").Select
        Range("I65536").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
        
        
        Cells.Replace what:=Chr(44), Replacement:=Chr(46)
    
    
    End Sub
    Last edited by eliasbyvasoula; Sep 6th, 2010 at 02:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width