+ Reply to Thread
Results 1 to 9 of 9

Copy Cell with Color

Hybrid View

rizmomin Copy Cell with Color 05-07-2007, 08:22 PM
mikerickson Range("a1:c5").Copy... 05-07-2007, 08:51 PM
rizmomin Thanks for you help...... 05-07-2007, 09:15 PM
mikerickson I'm guessing that this is... 05-07-2007, 09:27 PM
rizmomin I tried your suggestion and... 05-07-2007, 09:34 PM
  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Copy Cell with Color

    This must be very easy for lot of you.
    But i cant get this.
    What i want to do is following:

    Sheet1 Cell A1:c5 has values and different Cell color.

    i want VB code to copy Cell A1:C5 with same values and color at say H20...

    Please refer to attached sheet...

    Thank U

    Riz Momin
    Attached Files Attached Files

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Range("a1:c5").Copy Destination:=Range("H20")

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434
    Thanks for you help...
    Please refer to attached sheet and macro code below.

    Below is the code i am using to copy and paste cells.
    i have data from Column A,B,C E,F, H,I,J and am pasting in column M,N and O

    All is fine except when data from column A, B, C are pasting at location M87...i want it to be the same color....which as you can see is not happening. Please help me correct the code so that Cell color is achieved..

    Please make sure to run this code to understand what is happening..
     
    Sub Reg_TimeClock_New()
    ' This macro is Control+Shift+Y
    
      headarr = Array("GROSS TL", "GROSS SL", "REFUND", "DISCOUNT", "EMP DISC", "MGR DISC", "COIN RDM", "GIFT RDM", "GIFT CRT", " ", "NET SALE", "TAX TOTL", "'==============", "", "", "", "", "", "NO SALE", "DRAWER", "CASH DWR", "", "", "", "CHARGE 1", "", "TAXABLE1", "NON-TXBL", "'--------------", "BRAZIER", "DRINKS", "SOFT SER", "CAKES", "", "", "", "", "", "COUPON", "--------------", "S-GRP TL", "ITEMS TL", "M-GRP TL", "EAT-IN", "TAKE-OUT", "DR-THRU", "", "", "", "AVE DR-T", "OVR DR-T", "VOID TL", "CNCL ORD", "*AVPR", "GRAND TL*", "X1", "X2", "X3", "X4", "X5")
      
      outcol = 14
      Cells(2, outcol - 1).Resize(60, 1).Value = WorksheetFunction.Transpose(headarr)
      For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row Step 61
        Cells(1, outcol).Resize(61, 2).Value = Range(Cells(i, 5), Cells(i + 60, 6)).Value
        outcol = outcol + 4
        
      Next i
      
      outcol = 13
      i = 2
      startrow = 1
      While Not (IsEmpty(Cells(i, 8)))
        If Cells(i, 8) = "ID_CODE" Then
          Cells(64, outcol).Resize(i - startrow - 1, 3).Value = Range(Cells(startrow + 1, 8), Cells(i - 1, 10)).Value
          startrow = i
          outcol = outcol + 4
        End If
        i = i + 1
      Wend
      Cells(64, outcol).Resize(i - startrow - 1, 3).Value = Range(Cells(startrow + 1, 8), Cells(i - 1, 10)).Value
      
      outcol = 13
      i = 2
      startrow = 1
      While Not (IsEmpty(Cells(i, 1)))
      
        If Cells(i, 1) = "PLU_CODE" Then
          Cells(87, outcol).Resize(i - startrow - 1, 3).Value = Range(Cells(startrow + 1, 1), Cells(i - 1, 3)).Value
          ' This is pasting PLU's
          startrow = i
          End If
        i = i + 1
        If i = 356 Then
      Cells(i, 1) = ""
      End If
        Wend
        Cells(87, outcol).Resize(i - startrow - 1, 3).Value = Range(Cells(startrow + 1, 1), Cells(i - 1, 3)).Value
        
      Range("m1", Cells(1, Columns.Count).End(xlToLeft)).ClearContents
      Cells(1, 13).Select
    End Sub
    Thank U

    Riz Momin
    Attached Files Attached Files
    Last edited by VBA Noob; 05-08-2007 at 02:30 AM.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I'm guessing that this is where your problems are. Try adding the new line.
    If Cells(i, 1) = "PLU_CODE" Then
    Cells(87, outcol).Resize(i - startrow - 1, 3).Value = Range(Cells(startrow + 1, 1), Cells(i - 1, 3)).Value
    
    Cells(87, outcol).Resize(i - startrow - 1, 3).Interior.ColorIndex = Range(Cells(startrow + 1, 1), Cells(i - 1, 3)).Interior.ColorIndex
    ' This is pasting PLU's

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434
    I tried your suggestion and still would not work...

    Please help

    Riz Momin

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    go through all your code and whenever you set the .Value property, add a new line to change the .Interior.ColorIndex as well.

+ 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