作者: tinhon 時間: 2023-5-23 23:08 標題: 請教excel formula 寫法,有關對比時間,謝謝。
本帖最後由 tinhon 於 2023-5-23 23:33 編輯

假設以上為返工時間,好明顯第5列嘅AA 開始時間撞咗第2列嘅AA,有無得寫條formula去檢查呢啲相撞呢?

https://www.hkepc.com/forum/attachment.php?aid=2373844&k=cdfd49085afbcbdd0e55584257f313c9&t=1750009698&sid=1mYazKGKmwm

作者: cyberyeah 時間: 2023-5-24 07:17
點撞法?
via HKEPC IR 5.0.0 - Android(5.0.0F)
作者: bobopig 時間: 2023-5-24 13:06
本帖最後由 bobopig 於 2023-5-24 13:18 編輯
AA 第二行返 0800 放 1200
咁冇可能 AA 第五行 1000 又返緊工再打多一次卡返工
我諗佢係呢個意思。
係咪要係 b 行 set 2個 formula
1 要 c 行空白才可以入,代表未返過工。
2 如果 c 行有數就 b 行呢格要大過佢,代表放左工再返,例如放飯。
不過我唔識寫。 用 if + or ?
via HKEPC IR Pro 3.6.1 - Android(3.3.1)
作者: luckybear 時間: 2023-5-24 15:48
只用EXCEL內建函數?
如是會很難,牛人可能會
但如果想簡單用VBA處理
作者: Aÿ 時間: 2023-5-24 16:15
EXCEL如果做左sorting好易處理
唔做sorting咩都要由頭對到尾,寫VBA好過
作者: bobopig 時間: 2023-5-25 10:40
請教 VBA 會點寫?
VBA 好像是執行. 但如果係樓主個一刻輸入就要知結果. 是否可行?
或個羅輯, 大至會編?
謝謝.
作者: platinum 時間: 2023-5-25 13:59
參巧下
https://www.myonlinetraininghub. ... -and-times-in-excel
作者: luckybear 時間: 2023-5-25 17:08
這個不能做到篩選重複人,樓主是表找同一個人是否有重疉時間,如果要用這個要把每個人做一個time line表,對比時間會很長
作者: Aÿ 時間: 2023-5-25 17:22
樓主問完沒回覆,答VBA點寫都沒意思吧
何況VBA識寫嘅人就識寫
唔識嘅人,叫佢用VBA,學嘅時間可能仲長過慢慢做
作者: luckybear 時間: 2023-5-25 17:35
https://learn.microsoft.com/en-us/office/vba/api/excel.range.find
可以找到VBA Find的用法,例子有一個找相同值的可以修改一下來找相同人再記錄地址
Sub FindValue()
Dim c As Range
Dim firstAddress As String
Dim temp(10)<--用來暫存地址
With Worksheets(1).Range("A1:A500") <---Worksheet(1)要改你成你sheet個名
Set c = .Find(2, lookin:=xlValues) 把紅色成你要找的人名,要留意Cells內的人名有沒有空格
If Not c Is Nothing Then
firstAddress = c.Address Delete這行
Do
c.Value = 5 -->改成temp(i)=c.Address
Set c = .FindNext(c)
i=i+1
Loop While Not c Is Nothing
End If
End With
return temp<--把Cells的地址傳出去
End Sub
之後要寫個Sub用來轉時間資料,上網找找會有,不轉會不能比較所以一定要轉
轉完要再寫個Sub用來檢查之前轉完的時間有沒有重疊<--這個真的很難去一些討論區找人會不會,我不太會

之後要再寫一個Sub用來做Main program把上面那些Sub用這個來call out用
作者: tinhon 時間: 2023-5-26 18:26
我試緊呢段excel
=IF(COUNTIFS($B$1:$B$7,"<="&C1,$A$1:$A$7,A1)+COUNTIFS($C$1:$C$7,">="&B1,$A$1:$A$7,A1)>2,TRUE,FALSE)
作者: s84292 時間: 2023-5-27 17:34
呢個問題,最後我係用微軟teams個排更功能,貪佢可以匯出excel
excel 都係唔太適合呢個用法
作者: bongbong3481 時間: 2023-5-27 19:28
回覆 5# Aÿ
學到野

作者: Aÿ 時間: 2023-5-27 20:06
當然,根本system 跑個report出黎無sorting已經係病態
raw data出左csv/excel唔俾執都係病態
sort完 A同B column 之後,淨對兩個cell就check到overlap,例如AND(A2=A1,B2>C1)
當然,作為識寫program嘅人,又或者唔想人搞你formula/code嘅人,是但啦,點做無所謂
作者: dipsy 時間: 2023-5-30 14:41
我問 Bing AI, 佢咁答, 你試吓:
To check overlapping check-in and check-out times in an Excel table, you can use a formula that identifies overlapping dates and times. Here's how:
1. Create a new column next to your check-in and check-out times.
2. In the first cell of the new column, enter the following formula: =SUMPRODUCT(($B$2:$B$10<=B2)*($C$2:$C$10>=C2))>1
3. Copy the formula down to the other cells in the column.
4. The cells with "TRUE" values indicate overlapping check-in and check-out times.
This formula checks if each start date is less than any of the end dates in the table AND if each end date is greater than any of the start dates in the table¹.
I hope this helps! Let me know if you have any other questions.
來源: 與 Bing 的交談, 30/5/2023
(1) Identify overlapping dates and times in Excel - My Online Training Hub. https://www.myonlinetraininghub. ... and-times-in-excel.
(2) Identify Overlapping Dates and Times in Excel - EASY Formula. https://www.youtube.com/watch?v=V9jQ_Mitd-s.
(3) Grouping overlapping times in MS Excel - Super User. https://superuser.com/questions/ ... -times-in-ms-excel.
作者: tragamer 時間: 2023-6-2 16:33
(開始時間)係唔係包含日期?
開新頁排順序開始時間,
用maxifs/minifs符合相同(代號)加减時間,
可以試下

作者: lymi 時間: 2023-6-2 17:44
提示: 作者被禁止或刪除 內容自動屏蔽
作者: bobopig 時間: 2023-6-3 19:07
如果唔用 VBA, 用 FORMULA 會唔會較好?
作者: bobopig 時間: 2023-6-3 19:09
我問 Bing AI, 佢咁答, 你試吓:
To check overlapping check-in and check-out times in an Excel table, ...
dipsy 發表於 2023-5-30 14:41
BING 唔知點用, 我有時都係問 POE, 好似我另一個POST 咁問. 但佢覆我D詞語就未必明.
作者: tinhon 時間: 2023-6-3 20:01
事緣編完後唔可以sorting(真嗰個無example嗰個咁簡單),因為會亂到7彩。
我嘗試下用formula整,唔得嘅話再諗下計寫VBA。
謝謝咁多位師兄
作者: tragamer 時間: 2023-6-3 20:26
本帖最後由 tragamer 於 2023-6-4 01:49 編輯
我哋都想學下嘢, 如果有回饋, 當然好.
sorting 唔須要用原頁(sheet1)
係sheet2, =sort(sheet1!A1:C10,1,2)

作者: dipsy 時間: 2023-6-4 09:13
一樣咁用,佢背後係ChatGPT-4, 會online search 嘢,準d
via HKEPC IR 5.1.13 - iOS(5.1.1F)
作者: dominicyu 時間: 2023-6-9 08:10
本帖最後由 dominicyu 於 2023-6-9 08:15 編輯
你差緊個日子 如果無日子點知8點係今日定琴日 你時間最好日子加時間
然後分 返工同 放工2組Data
乜Excel Formula Vba 都唔駛識用
用Sorting 就知人每天最細返工時間 同最大放工時間
一係返同放工 放埋同一行最大最小一目了然
好奇問下點解出閘入閘都用唔同機
作者: ukkf 時間: 2023-6-9 15:35
最精簡應該係用sql寫, 可以import入access行或者研究下excel直接行sql
SELECT *
FROM mytable a
JOIN mytable b on a.starttime <= b.endtime
and a.endtime >= b.starttime
and a.name = b.name;
via HKEPC IR 5.1.14 - Android(5.1.2F)
作者: bongbong3481 時間: 2023-6-10 19:42
回覆 1# tinhon
我諗到1個簡單方法,畫橫條圖,重疊的,一眼睇晒