Create copy with insert into new sheet use VBA

leodo2x

New Member
Joined
Jun 15, 2015
Messages
1
Dear Master,
Could you please advise
I would like copy the data in the new row other sheet

below is the screen shoot what should it be
Sheet 1
There are date, people , and color + number
https://drive.google.com/file/d/0B995E_xrlb3STzd5VG5Jd2lmdVU/view?usp=sharing
view

Sheet 2
If color is brown then copy value from sheet 1 and paste to sheet 2 with name Color A for brown ( depend on the date and people)
if color is yellow then copy value from sheet 1 create new row below brown Name color C for yellow ( Depend on the date )
if no color then do nothing
https://drive.google.com/file/d/0B995E_xrlb3SQk40ZWk4dU0tSzQ/view?usp=sharing
view


below is my code, but doesn't work . Please help and advise
Dim k, x
Dim inter As Worksheet
Dim ws As Worksheet
Dim rng As Range
Dim cell As Range


Set inter = ThisWorkbook.Worksheets("Sheet2")
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set rng = Range("People")
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True

For Each cell In rng
For k = 6 To 12
If ws.Cells(cell.ROW, k).Interior.ColorIndex = 53 Then
inter.Cells(cell.ROW + x, 5).Value = "A"
inter.Cells(cell.ROW + x, k).Value = ws.Cells(cell.ROW, k).Value
ElseIf ws.Cells(cell.ROW, k).Interior.ColorIndex = 37 Then
inter.Cells(cell.ROW + x, 5).Value = "B"
inter.Cells(cell.ROW + x, k).Value = ws.Cells(cell.ROW, k).Value
ElseIf ws.Cells(cell.ROW, k).Interior.ColorIndex = 6 Then
inter.Cells(cell.ROW + x, 5).Value = "C"
inter.Cells(cell.ROW + x, k).Value = ws.Cells(cell.ROW, k).Value
ElseIf ws.Cells(cell.ROW, k).Interior.ColorIndex = 55 Then
inter.Cells(cell.ROW + x, 5).Value = "D"
inter.Cells(cell.ROW + x, k).Value = ws.Cells(cell.ROW, k).Value
ElseIf ws.Cells(cell.ROW, k).Interior.ColorIndex = 46 Then
inter.Cells(cell.ROW + x, 5).Value = "D"
inter.Cells(cell.ROW + x, k).Value = ws.Cells(cell.ROW, k).Value
Else

End If
x = x + 1
Next k
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top