simple but not so simple formula needed (or vba?)

auzanoo

Board Regular
Joined
Jan 6, 2020
Messages
63
Office Version
  1. 2007
Platform
  1. Windows
dear experts,

i have to make this (sample) data from this:
1635830472890.png


to this:
1635830498460.png


so,
1. the date just has to be unique,
2. the start time is from the first column, and then the end time is from the last column (of the date).
3. the row A and B must be from the summary.

i just confused about how to do the formula (or maybe using VBA?). the actual data is so big.


thanks in advance!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Are you still using Ex2007? I intend to use modern formula AGGREGATE which is for Ex2010 or later.
 
Upvote 0
For the future, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

Give this a try. It assumes that the data is on "Sheet1". Edit the code if required, or advise if the data will always be on the active sheet when the code is run.
The code creates a new sheet with the results.

VBA Code:
Sub Rearrange()
  Dim rA As Range
  
  Application.ScreenUpdating = False
  Sheets("Sheet1").Copy Before:=Sheets(1)
  With Sheets(1)
    .UsedRange.MergeCells = False
    For Each rA In .Range("C2", .Range("C" & Rows.Count).End(xlUp)).SpecialCells(xlConstants, xlTextValues).Areas
      With rA
        .Cells(1).Value = Left(.Cells(1).Value, 11) & Right(.Cells(.Count).Value, 8)
        .Cells(1, 2).Resize(, 2).Value = .Cells(.Count + 1, 2).Resize(, 2).Value
        .EntireRow.Offset(1).Delete
      End With
    Next rA
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
For the future, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

Give this a try. It assumes that the data is on "Sheet1". Edit the code if required, or advise if the data will always be on the active sheet when the code is run.
The code creates a new sheet with the results.

VBA Code:
Sub Rearrange()
  Dim rA As Range
 
  Application.ScreenUpdating = False
  Sheets("Sheet1").Copy Before:=Sheets(1)
  With Sheets(1)
    .UsedRange.MergeCells = False
    For Each rA In .Range("C2", .Range("C" & Rows.Count).End(xlUp)).SpecialCells(xlConstants, xlTextValues).Areas
      With rA
        .Cells(1).Value = Left(.Cells(1).Value, 11) & Right(.Cells(.Count).Value, 8)
        .Cells(1, 2).Resize(, 2).Value = .Cells(.Count + 1, 2).Resize(, 2).Value
        .EntireRow.Offset(1).Delete
      End With
    Next rA
  End With
  Application.ScreenUpdating = True
End Sub

thanks for the future suggestion. i'll do that.

thank you so much for the code, Mr. Peter. it perfectly works. much love!
(sorry for the late response)
 
Upvote 0

Forum statistics

Threads
1,223,785
Messages
6,174,540
Members
452,571
Latest member
MarExcelTips

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