作者: lvanb 時間: 2023-10-11 13:15 標題: EXCEL FIND WORDS In ONE CELL
如何在EXCEL找到某CELL 含有二個字
但這二字不是相連的
例如: WORK BUS
任何CELL 祗要有這二字, 即使非相連, 都可找到
GOOGLE過, 但並非我相要的
謝謝
作者: javacomhk 時間: 2023-10-11 17:49
Regular expression match this
.*?(WORK).*?(BUS).*?
作者: bongbong3481 時間: 2023-10-11 19:04
留名學野
作者: bongbong3481 時間: 2023-10-11 19:10
我暫時想到用2個countinif (cell ,"*keyword*")相加,
結果是2應該就有果兩個字
作者: dipsy 時間: 2023-10-12 11:29
問咗Bard
=AND(COUNTIF(A1:B1,"*WORK*")>=1,COUNTIF(A1:B1,"*BUS*")>=1)
如果是 true 就係有晒 WORK 同BUS
作者: lvanb 時間: 2024-1-26 21:29
謝謝大家
作者: s20012797 時間: 2024-1-27 13:11
- def find_unconnected_words():
- word1 = input("Enter the first word:")
- word2 = input("Enter the second word:")
- found_cells = []
- for row in range(1, sheet.max_row + 1):
- for column in range(1, sheet.max_column + 1):
- cell_value = sheet.cell(row=row, column=column).value
- if word1 in cell_value and word2 in cell_value:
- found_cells.append((row, column))
- for cell in found_cells:
- print(f"Cell at ({cell[0]}, {cell[1]})")
- find_unconnected_words()
作者: lvanb 時間: 2024-2-17 10:43
thank you
作者: jimking332 時間: 2024-2-19 10:51
呢D唔係Excel VBA, 請問係咩code?
作者: bongbong3481 時間: 2024-2-19 16:29
回覆 9# jimking332
應該是python
作者: s20012797 時間: 2024-2-19 17:29
用VBA寫煩好多Lo
- Sub FindUnconnectedWords()
- Dim Word1 As String
- Dim Word2 As String
- Dim FoundCells As Collection
- Dim Row As Long
- Dim Column As Long
- Dim CellValue As String
- Dim Cell As Range
- Dim FoundCell As Range
- Word1 = InputBox("Enter the first word:")
- Word2 = InputBox("Enter the second word:")
- Set FoundCells = New Collection
- For Row = 1 To ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
- For Column = 1 To ThisWorkbook.Sheets(1).Cells(1, Columns.Count).End(xlToLeft).Column
- CellValue = ThisWorkbook.Sheets(1).Cells(Row, Column).Value
- If InStr(1, CellValue, Word1) > 0 And InStr(1, CellValue, Word2) > 0 Then
- FoundCells.Add ThisWorkbook.Sheets(1).Cells(Row, Column)
- End If
- Next Column
- Next Row
- For Each FoundCell In FoundCells
- Debug.Print "Cell at (" & FoundCell.Row & ", " & FoundCell.Column & ")"
- Next FoundCell
- End Sub
作者: bongbong3481 時間: 2024-2-19 17:53
回覆 11# s20012797
唔用DIM , 應該可以刪幾行, 另外, 樓上有D POST 用公式整都好似得

