I have posted the problem before on
It used the if function and it works perfectly
The problem is that the data that taken to the master data is automatically run by VBA and it can't add the row automatically which also it takes time to insert the row (cause the sheet now reach until more then 15)
I have a code but it only takes the C column data and not the E column data
here's the code
what should I change in order to meet the criteria as my past post?
thank you
formula to autofill with condition and skip blank cells
I have the master sheet and data sheet (more than 1 but same format) This is the example of the data from the sheet Project Details Project A Laptop Printer Camera Blank Phone Projector Project C Implementation Debug Smart TV what I need...
www.mrexcel.com
It used the if function and it works perfectly
The problem is that the data that taken to the master data is automatically run by VBA and it can't add the row automatically which also it takes time to insert the row (cause the sheet now reach until more then 15)
I have a code but it only takes the C column data and not the E column data
here's the code
VBA Code:
Sub Macro2()
Dim ws As Worksheet, MasterSheet As Worksheet
Dim originalDestinationCell As Range, nextDestCell As Range
Dim firstGreyCell As Range, rangeToSearchIn As Range, c As Range
Set MasterSheet = Sheets("Sheet1") 'where you want to put the copied data
Set originalDestinationCell = MasterSheet.Range("C6") 'the first cell the data will be copied to
Set nextDestCell = originalDestinationCell.Offset(-1, 0)
For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = MasterSheet.Name Then
Set firstGreyCell = ws.Range("C6")
Set rangeToSearchIn = ws.Range("C6:C1500") 'the range that the data is in
For Each c In rangeToSearchIn
If IsEmpty(c) = False Then 'only copy if the cell is not blank
If c.Interior.Color = firstGreyCell.Interior.Color Then
'if the interior color of cell 'c' is the same as 'firstGreyCell' then
Set nextDestCell = MasterSheet.Cells(nextDestCell.Row + 1, originalDestinationCell.Column)
'move the next cell down one column and back to the original column
nextDestCell.Value = c.Value 'copy the value to the recap sheet
nextDestCell.Interior.Color = c.Interior.Color 'copy the cell color too
Else
'if the interior color is not the same as 'c'
Set nextDestCell = nextDestCell.Offset(0, 2) 'move the nextDestCell to the right by 1
nextDestCell.Value = c.Value 'copy its value
End If
End If
Next c
End If
Next ws
End Sub
what should I change in order to meet the criteria as my past post?
thank you