我有一个excel列,其中包含数据,但每个单元格都包含多行数据。有些行是空的,有些行是填充的。现在,我只想提取包含特定单词(例如“运费”)的那一行。非常感谢大家。
最好的问候
答案 0 :(得分:0)
这可能是一个开始。我在D列中搜索“运输”一词。找到后,将单元格值复制到E列。
代码:
Sub FindValue()
Dim ColNum As Integer
Dim SearchWord As String
Dim lrow As Integer
ColNum = 4 'Which Column you want to search for (4 = Column D)
SearchWord = "shipping" 'Which word you want to search for
lrow = 11 'How many rows you want to search in
For i = 1 To lrow 'Loop from first row until lrow (which you define above)
ValueLookup = Cells(i, ColNum).Value
If InStr(1, ValueLookup, SearchWord, 1) Then 'Compare the value in ValueLookup against your Search Word
'When ValueLookup contain the SearchWord Then do something
Cells(i, ColNum).Offset(0, 1) = ValueLookup 'Here I just offset the found value with one column
End If
Next i
End Sub
答案 1 :(得分:0)
尝试一下:
=IF(ISERR(FIND("shipping",LOWER(B1))),0,FIND("shipping",LOWER(B1)))
“ IF(ISERR())”消除了任何难看的“ #VALUE!”错误讯息 “ LOWER()”可确保不会忽略大小写混合的单词