Paste data based on cell color

hardeep.kanwar

Well-known Member
Joined
Aug 13, 2008
Messages
693
Hi Experts

We have data (know as Time sheet) where employees are putting there daily time every day and my task to check putting more then 8 Hr (Basically more than 10 Hrs),so i highlight the data by using Find Function and highlights those cells.

Now i am doing manually copy paste the data of each employee (Total 218) one by one.

Is there any way to paste only data data to another sheet.


Name1-Nov-242-Nov-243-Nov-244-Nov-24
A8888
B8888
C8888
D8888
E8888
F8181214
G8888
H8888
I812118
J8888
K8888
L8101315
M8888
N8888
O12131416
P8888






Name1-Nov-242-Nov-243-Nov-244-Nov-24
F 181214
I 1211
L 101315
O12131416
 
Last edited by a moderator:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Sorry to forget the data
 

Attachments

  • Timesheet.png
    Timesheet.png
    37.2 KB · Views: 5
Upvote 0
Assuming ..
  1. Your original data is on Sheet1
  2. Results to go on Sheet2
  3. Sheet2 already exists
  4. Any data already on Sheet2 can be deleted
.. then try this with a copy of your workbook.
Note that this does not use the highlight colour, it just transfers the data if the cell value > 8.

VBA Code:
Sub Overtime()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, uba2 As Long
 
  a = Sheets("Sheet1").Range("A1").CurrentRegion.Value
  uba2 = UBound(a, 2)
  ReDim b(1 To UBound(a), 1 To uba2)
  For i = 1 To UBound(a)
    For j = 2 To uba2
      If a(i, j) > 8 Then
        b(i, 1) = a(i, 1)
        b(i, j) = a(i, j)
      End If
    Next j
  Next i
  With Sheets("Sheet2")
    .UsedRange.ClearContents
    With .Range("A1").Resize(UBound(a), uba2)
      .Value = b
      On Error Resume Next
      .Columns(1).SpecialCells(xlBlanks).EntireRow.Delete
      On Error GoTo 0
    End With
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,809
Messages
6,181,075
Members
453,020
Latest member
mattg2448

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