+ Reply to Thread
Results 1 to 3 of 3

Making Copy and Paste Code more efficient

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    171

    Making Copy and Paste Code more efficient

    Hi, I was just wondering how to shorten the code below, many Thanks

    '2a)Copy Work Orders from Monthly to Cumulative
    Range(Cells(2, wocol), Cells(monthlastrow, wocol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("C" & cumlastrow + 1)


    '2b)Copy Specialisms from Monthly to Cumulative
    Range(Cells(2, speccol), Cells(monthlastrow, speccol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("D" & cumlastrow + 1)

    '2c)Copy Customer from Monthly to Cumulative
    Range(Cells(2, custidcol), Cells(monthlastrow, custidcol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("E" & cumlastrow + 1)

    '2d)Copy Description from Monthly to Cumulative
    Range(Cells(2, desccol), Cells(monthlastrow, desccol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("F" & cumlastrow + 1)

    '2e)Copy Billing from Monthly to Cumulative
    Range(Cells(2, billcol), Cells(monthlastrow, billcol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("G" & cumlastrow + 1)

    '2f)Copy PM from Monthly to Cumulative
    Range(Cells(2, promancol), Cells(monthlastrow, promancol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("H" & cumlastrow + 1)


    '2g)Copy Hearby from Monthly to Cumulative
    Range(Cells(2, hbcol), Cells(monthlastrow, hbcol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("I" & cumlastrow + 1)

    '2h)Copy Date proposal from Monthly to Cumulative
    Range(Cells(2, dpcol), Cells(monthlastrow, dpcol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("J" & cumlastrow + 1)

    '2i)Copy Status from Monthly to Cumulative
    Range(Cells(2, statcol), Cells(monthlastrow, statcol)).Copy _
    Destination:=Worksheets("CUMPROP").Range("K" & cumlastrow + 1)

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    You could replace your column variables (wocol, speccol, custidcol etc) with an array. Call it col_array, so that

    col_array(0) = wocol
    col_array(1) = speccol
    etc...

    then your code below can be replaced with:

    Please Login or Register  to view this content.

    Col
    Last edited by colofnature; 09-18-2006 at 10:24 AM.
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    171
    Many Thanks Col

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1