Try this code..
Sub test()
Application.ScreenUpdating = False
Dim sh As Object
Dim i As Integer
Dim nwkb As Object
Dim lrow As Long
Set nwkb = Workbooks.Add
nwkb.Sheets(1).Cells(1, 1).Value = "Date"
nwkb.Sheets(1).Cells(1, 2).Value = "Emp code"
nwkb.Sheets(1).Cells(1, 3).Value = "Time"
nwkb.Sheets(1).Cells(1, 4).Value = "DDMM"
nwkb.Sheets(1).Cells(1, 5).Value = "HHMM"
nwkb.Sheets(1).Cells(1, 6).Value = "Empcd"
nwkb.Sheets(1).Cells(1, 7).Value = "Final output"
ThisWorkbook.Activate
For Each sh In ThisWorkbook.Sheets
For i = 1 To sh.Cells(Rows.Count, 1).End(xlUp).Row
For j = 4 To sh.Cells(1, Columns.Count).End(xlToLeft).Column
If sh.Cells(i, 1).Value <> sh.Cells(i + 1, 1).Value Then
lrow = nwkb.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row + 1
nwkb.Sheets(1).Cells(lrow, 1).Value = sh.Cells(1, j).Value
nwkb.Sheets(1).Cells(lrow, 2).Value = sh.Cells(i + 1,
1).Value
nwkb.Sheets(1).Cells(lrow, 3).Value = sh.Cells(i + 1,
j).Value
End If
Next j
Next i
Next sh
nwkb.Activate
Cells.Columns.AutoFit
Application.ScreenUpdating = True
End Sub
--
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
https://www.facebook.com/discussexcel
FORUM RULES
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
NOTE : Don't ever post confidential data in a workbook. Forum owners and
members are not responsible for any loss.
---
You received this message because you are subscribed to the Google Groups "MS
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.