Split Time Range into Half Hour Each Row

disyn

New Member
Joined
Apr 24, 2020
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I have a data set that look like this

NameActivityDetailStartFinish
BobCookingCooking pasta22/04/2020 9:0022/04/2020 10:00
BillReadingReading novel22/04/2020 9:3022/04/2020 10:00

And i want to split it like this

NameTimeActivityDetail
Bob22/04/2020 9:00CookingCooking pasta
Bob22/04/2020 9:30CookingCooking pasta
Bill22/04/2020 9:30ReadingReading Novel

Any excel formula idea or vba macro code idea? Thank you!
 
Replace formulas

varios 27abr2020.xlsm
GHIJKLMNOPQ
1Activity NoUserActivityDescriptionDayMonthYearStart TimeEnd TimeDate StartDate End
2A-1Staff 3testtest56202009:00:00 a.m.10:00:00 a.m.05/06/2020 09:0005/06/2020 10:00
3A-2Staff 4test1test148202008:30:00 a.m.09:30:00 a.m.04/08/2020 08:3004/08/2020 09:30
Sheet6
Cell Formulas
RangeFormula
P2:P3P2=(TEXT(DATE([Year],[Month],[Day]),"dd/mm/yyyy ")&TEXT([Start Time],"hh:mm"))+0
Q2:Q3Q2=(TEXT(DATE([Year],[Month],[Day]),"dd/mm/yyyy ")&TEXT([End Time],"hh:mm"))+0


Use this code in userform:

VBA Code:
Private Sub CommandButton3_Click() 'submit button
  Dim indeks As Integer
  With Sheet6.ListObjects("Tabel_Activity")
    .ListRows.Add AlwaysInsert:=True
    indeks = .ListRows.Count + 1
    .Range.Cells(indeks, 1) = "A-" & indeks
    .Range.Cells(indeks, 2) = ComboBox1.Value
    .Range.Cells(indeks, 3) = TextBox1.Value
    .Range.Cells(indeks, 4) = TextBox2.Value
    .Range.Cells(indeks, 5) = Val(ComboBox2.Value)  'day
    .Range.Cells(indeks, 6) = Val(ComboBox3.Value)  'month
    .Range.Cells(indeks, 7) = Val(ComboBox4.Value)  'year
    .Range.Cells(indeks, 8) = ComboBox5.Value       'start
    .Range.Cells(indeks, 9) = ComboBox8.Value       'end
  End With
  Unload Me
End Sub

Try again
thank you so much, it works. anyway, i want to ask additional question, how should i format 12:00 pm o'clock for the combobox? because it appears as 12:05 am instead
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Something like this:

VBA Code:
Private Sub UserForm_Activate()
  Dim i
  For i = TimeValue("00:00") To TimeValue("23:31") Step TimeValue("00:30")
    ComboBox5.AddItem Format(i, "hh:mm AM/PM")
  Next
End Sub
 
Upvote 0
Something like this:

VBA Code:
Private Sub UserForm_Activate()
  Dim i
  For i = TimeValue("00:00") To TimeValue("23:31") Step TimeValue("00:30")
    ComboBox5.AddItem Format(i, "hh:mm AM/PM")
  Next
End Sub
i tried that but it show error 70 permission denied, any idea?
 
Upvote 0
Replace formulas

varios 27abr2020.xlsm
GHIJKLMNOPQ
1Activity NoUserActivityDescriptionDayMonthYearStart TimeEnd TimeDate StartDate End
2A-1Staff 3testtest56202009:00:00 a.m.10:00:00 a.m.05/06/2020 09:0005/06/2020 10:00
3A-2Staff 4test1test148202008:30:00 a.m.09:30:00 a.m.04/08/2020 08:3004/08/2020 09:30
Sheet6
Cell Formulas
RangeFormula
P2:P3P2=(TEXT(DATE([Year],[Month],[Day]),"dd/mm/yyyy ")&TEXT([Start Time],"hh:mm"))+0
Q2:Q3Q2=(TEXT(DATE([Year],[Month],[Day]),"dd/mm/yyyy ")&TEXT([End Time],"hh:mm"))+0


Use this code in userform:

VBA Code:
Private Sub CommandButton3_Click() 'submit button
  Dim indeks As Integer
  With Sheet6.ListObjects("Tabel_Activity")
    .ListRows.Add AlwaysInsert:=True
    indeks = .ListRows.Count + 1
    .Range.Cells(indeks, 1) = "A-" & indeks
    .Range.Cells(indeks, 2) = ComboBox1.Value
    .Range.Cells(indeks, 3) = TextBox1.Value
    .Range.Cells(indeks, 4) = TextBox2.Value
    .Range.Cells(indeks, 5) = Val(ComboBox2.Value)  'day
    .Range.Cells(indeks, 6) = Val(ComboBox3.Value)  'month
    .Range.Cells(indeks, 7) = Val(ComboBox4.Value)  'year
    .Range.Cells(indeks, 8) = ComboBox5.Value       'start
    .Range.Cells(indeks, 9) = ComboBox8.Value       'end
  End With
  Unload Me
End Sub

Try again
anyway it's a bit weird, i use this coding and also formula you have given for the table. it runs well but the content of activity number (A-indeks) always skips one number. For example, if the last row is A-4, when i add new activity from userform, the next activity number is A-6. I tried to modify the "A-" & indeks part become "A-" & indeks-1. The activity number comes in sequence but the formula to in P and Q column show #VALUE error. Could you please help me to solve this little error?
 
Upvote 0
i tried that but it show error 70 permission denied, any idea?
How do you load combo5 and combo8? with Rowsource?
You can put here all the code of your userform.
___________________________________________________________________________
For example, if the last row is A-4, when i add new activity from userform, the next activity number is A-6.
Check that you have no blank rows in the table.
 
Upvote 0
I have no problems, neither with the table, nor with the formulas, nor with the consecutive one, nor with the Split.



1588082027909.png

Do you need to have the data in a Table?

It is more practical if you had the data in a normal range of cells. But it is your information.
 
Upvote 0
I have no problems, neither with the table, nor with the formulas, nor with the consecutive one, nor with the Split.



View attachment 12526
Do you need to have the data in a Table?

It is more practical if you had the data in a normal range of cells. But it is your information.
i have tried again and finally there is no problem with the table and splitting. but i still encounter error with 12:00. I use this rowsource for combobox 5. the 12:00 o'clock in the table stated 12:00 PM but every time i choose 12:00 in combobox, it shows 12:05 instead.

8:30​
9:00​
9:30​
10:00​
10:30​
11:00​
11:30​
12:00​
12:30​
13:00​
13:30​
14:00​
14:30​
15:00​
15:30​
16:00​
16:30​
17:00​
17:30​
 
Upvote 0
i inputted the rowsource on combobox properties, like this one
1588140347297.png
 
Upvote 0
I have no problems, neither with the table, nor with the formulas, nor with the consecutive one, nor with the Split.



View attachment 12526
Do you need to have the data in a Table?

It is more practical if you had the data in a normal range of cells. But it is your information.
Anyway i have a question, is it possible if i delete a row in the initial table via the userform and then the row in result table also be deleted?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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