trying run this on a test workbook, but I am getting an Object error.
This is a test that will be applied to the proper workbook once it is finalised, there are more columns in the proper workbook than are currently in the test workbook to simplify things.
The test workbook has two worksheets, "DATA" and "ESTIMATE"
DATA is the source worksheet and ESTIMATE is the destination.
I am trying to copy non-contiguous cells from each row of the source worksheet "DATA" to the destination worksheet "ESTIMATE"
The rows that need to be copied are indicated in column7 "MARK" with an 'X' This is the factor for selecting which rows to copy.
DATA consists of seven columns in this test workbook.
Column1 = Title - Data required to copy
Column2 = NR1 - Data not required in this test
Column3 = Data1 - Required to Sum
Column4 = Data2 - Required to Sum
Column5 = NR2 - data not required in this test
Column6 = Data3 - Data required to copy
Column7 = Mark - indicates which rows to to be copied
Columns 3(Data1) & 4(Data2) need to be summed and the result placed in the destination worksheet "ESTIMATE".The individual cell data is not required to be copied, only the result.
So the row/cells of Columns 1 & 6 are copied and the results of the sum of row/cells in columns 3 & 4 are pasted to the destination worksheet.
The destination worksheet will have previous data that has been copied across so needs to start at the next available row of the destination worksheet.
'If at first you don't succeed, then your hammer is below specifications'
This is a test that will be applied to the proper workbook once it is finalised, there are more columns in the proper workbook than are currently in the test workbook to simplify things.
The test workbook has two worksheets, "DATA" and "ESTIMATE"
DATA is the source worksheet and ESTIMATE is the destination.
I am trying to copy non-contiguous cells from each row of the source worksheet "DATA" to the destination worksheet "ESTIMATE"
The rows that need to be copied are indicated in column7 "MARK" with an 'X' This is the factor for selecting which rows to copy.
DATA consists of seven columns in this test workbook.
Column1 = Title - Data required to copy
Column2 = NR1 - Data not required in this test
Column3 = Data1 - Required to Sum
Column4 = Data2 - Required to Sum
Column5 = NR2 - data not required in this test
Column6 = Data3 - Data required to copy
Column7 = Mark - indicates which rows to to be copied
Columns 3(Data1) & 4(Data2) need to be summed and the result placed in the destination worksheet "ESTIMATE".The individual cell data is not required to be copied, only the result.
So the row/cells of Columns 1 & 6 are copied and the results of the sum of row/cells in columns 3 & 4 are pasted to the destination worksheet.
The destination worksheet will have previous data that has been copied across so needs to start at the next available row of the destination worksheet.
Code:
Sub copyPasteTest()
For Each Mrk In Range("G2:G" & Cells(Rows.Count, 1).End(xlUp).Row)
If Not IsEmpty(Mrk) Then
With Worksheets("Estimate").Cells(Rows.Count, 1).End(xlUp).Row
.Value = .Value + Worksheets("data").Cells(1, 1).Value
.Value = .Value + Worksheets("data").Cells(1, 3).Value + .Value = .Value + Worksheets("data").Cells(1, 4).Value
.Value = .Value + Worksheets("data").Cells(1, 6).Value
End With
End If
Next ce
End Sub
'If at first you don't succeed, then your hammer is below specifications'