+ Reply to Thread
Results 1 to 3 of 3

Modify VBA code to copy values only

  1. #1
    Registered User
    Join Date
    05-16-2005
    Posts
    2

    Question Modify VBA code to copy values only

    Hello,
    I was wondering if anyone might know how to modify the following code so that it does Not replace the destination cells formating. (i.e. background color, borders, etc...)


    The following code is part of that which is used to populate a schedule based on which number is entered into a piticular cell. [12 week rotation]
    -----Start code example-----

    Select Case Worksheets("WeekRotations").Range("d2")
    Case "1"

    ' Start of Sunday for week one

    Worksheets("WeekRotations").Range("hs1sun").Copy _
    Destination:=Worksheets("rotcopy").Range("kevinSun")

    Worksheets("WeekRotations").Range("hs2sun").Copy _
    Destination:=Worksheets("rotcopy").Range("mattSun")

    -----End code example (code continues like that for 6 people / twelve weeks)-----
    Notes: hs1sun, kevinSun, etc... all refer to Named Ranges


    I know it would likely have been easier to do the whole thing with a simple array but I did not have the time to figure it out. (Haven't coded much in the last 3-4 years)

  2. #2
    Registered User
    Join Date
    05-16-2005
    Posts
    2
    Found the answer - thanks

  3. #3
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Have you tried a pastespecial instead of just copy to destination?

    For example, replace:

    Worksheets("WeekRotations").Range("hs1sun").Copy _
    Destination:=Worksheets("rotcopy").Range("kevinSun")


    With

    Worksheets("WeekRotations").Range("hs1sun").Copy
    Worksheets("rotcopy").Range("kevinSun").pastespecial Paste:=xlValues


    Hope this helps.

+ 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