EXCEL中VB程式設計關於模糊判斷單元文字的問題(程式設計高手進)

2022-06-19 21:52:14 字數 1121 閱讀 1023

1樓:匿名使用者

t=range("a1").value

if instr(1,t,"糖")>0 and instr(1,t,"連")=0 and instr(1,t,"指")=0 then

range("a2")=range("a1")else

range("a2")=""

end if

子易空間站 - excel培訓專家

2樓:匿名使用者

呵呵,vba做這個還是夠簡單的!

3樓:匿名使用者

sub test()

dim a1 as string

a1 = thisworkbook.sheets(1).cells(1, 1) '單元格a1的值賦值到變數a1中

if instr(a1, "糖") > 0 and instr(a1, "連") = 0 and instr(a1, "指") = 0 then '如果字串含有糖字,但沒有連和指字

thisworkbook.sheets(1).cells(2, 1) = thisworkbook.sheets(1).cells(1, 1) '單元格a2=1

else

thisworkbook.sheets(1).cells(2, 1) = "" '單元格a2為空

end if

end sub

4樓:天天過節

private sub commandbutton1_click()if instr(cells(1, 1), "糖") thenif instr(cells(1, 1), "連") or instr(cells(1, 1), "指") then

cells(2, 1) = ""

else

cells(2, 1) = cells(1, 1)end if

end if

end sub

5樓:快樂_無敵

instr函式

返回指定字元在字串中的位置,如果沒有則返回0

一個關於vb程式設計的問題,關於VB程式設計的小問題

private sub command1 mousemove button as integer,shift as integer,x as single,y as single dim myvalue randomize myvalue int rnd 1 生成 窗體高度內的一個隨機數值。myva...

在vb程式設計中如何把小寫變成大寫,VB中如何把原來字母中的小寫改為大寫,大寫改為小寫

vb6.0可使用ucase 函式可將小寫字母變成大寫。ucase 函式,返回 variant string 其中包含轉成大寫的字串。ucase 函式示例 本示例使用 ucase 函式來將某字串轉成全部大寫。說明,只有小寫的字母會轉成大寫 原本大寫或非字母之字元保持不變。dim lowercase,u...

關於vb中的for迴圈語句,關於VB中的for迴圈語句?

for i 0 to 10 step 2,意思是第一次執行時,i 1,下一次時i 1 2,在下一次i i 2 2,直到i 10結束 如果為負數 for i 10 to 1 step 2,那麼就是第一次i 10.第二次i 10 2,第三次10 2 2,直到i 0結束 步長就跟咱們走路一樣啊。比如路程是...