Solved Copy Multiple Cells instead of Single Cell Excel Code Update

Microsoft Excel 2010 - complete product...
November 3, 2014 at 07:05:59
Specs: Windows 7 Service Pack 1
Hi,

I have the following code which works, but I want to also copy "T" and "U" as well. Is there a way to modify the code below to do this?

Sub CopyLaborHrs()


Dim i, LastRow

LastRow = Sheets("Component Labor Summary").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Labor Hr Breakdown").Range("A2:V500").ClearContents
For i = 2 To LastRow
If Sheets("Component Labor Summary").Cells(i, "U").Value > "0.00" Then
Sheets("Component Labor Summary").Cells(i, "A").Copy _

Sheets("Labor Hr Breakdown").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
Next i

End Sub

Thank you Sandi


See More: Copy Multiple Cells instead of Single Cell Excel Code Update

Report •


#1
November 3, 2014 at 08:09:51
✔ Best Answer
First, a posting tip:

Please click on the blue line at the end of this post and read the instructions on how to use the pre tags to post VBA code in this forum so that it is easier for us to read.

As far as your question, I assume that you want the values in Columns T & U copied to Columns T & U on the Labor Hr Breakdown sheet.

I have posted the modified code below, but I would like to suggest that you review the material in this tutorial so that you can learn how to make these modifications on your own. We are more than willing to help, but the more you understand about VBA code, the easier it will be for you - and us. ;-)

http://www.computing.net/howtos/sho...

Sub CopyLaborHrs()
Dim i, LastRow, dstRw
'Determine last row with data in Column A of Component Labor Summary sheet
  LastRow = Sheets("Component Labor Summary").Range("A" & Rows.Count).End(xlUp).Row
'Clear range on Labor Hr Breakdown sheet
    Sheets("Labor Hr Breakdown").Range("A2:V500").ClearContents
'Loop through Column U of Component Labor Summary, copying
'data to Labor Hr Breakdown sheet if U value > 0
      For i = 2 To LastRow
        If Sheets("Component Labor Summary").Cells(i, "U").Value > "0.00" Then
'Determine next empty row in Labor Hr Breakdown sheet
         dstRw = Sheets("Labor Hr Breakdown").Range("A" & Rows.Count).End(xlUp).Row + 1
'Copy data from Column A, T & U
          Sheets("Component Labor Summary").Cells(i, "A").Copy
            Sheets("Labor Hr Breakdown").Range("A" & dstRw).PasteSpecial xlPasteValues
          Sheets("Component Labor Summary").Cells(i, "T").Copy
            Sheets("Labor Hr Breakdown").Range("T" & dstRw).PasteSpecial xlPasteValues
          Sheets("Component Labor Summary").Cells(i, "U").Copy
            Sheets("Labor Hr Breakdown").Range("U" & dstRw).PasteSpecial xlPasteValues
        End If
      Next i
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
November 3, 2014 at 09:54:06
That worked perfectly...THANK YOU!! I will review the tips as well.

Report •

Related Solutions


Ask Question