作者oycoyc (.......)
看板Visual_Basic
標題[VBA ] 關於excel的問題
時間Wed Nov 12 22:14:02 2008
我要計算sheet2中有幾個column,
因為每個column的最開始都固定是"nA"字串,
所以我的程式碼如下,
Sub 按鈕1_Click()
Dim i As Integer
i = 1
Do while Sheet2.Cells(1, i) = nA
i = i + 1
Loop
'在sheet1顯示出有幾個column
Sheet1.Cells(1, 2) = i - 1
End Sub
結果答案都是0,
奇怪的是我把判斷式改為
Sheet2.Cells(1,i) <> nA
之後,
答案竟然正確了!?
怎麼邏輯剛好相反?
是我哪裡搞錯了嗎?
煩請諸位高手指點迷津為小弟,感謝!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.20.9
→ MOONRAKER:阿你 nA 要寫成 "nA" 吧 11/12 22:36
→ oycoyc:不用加" "才可以 11/12 22:39
→ MOONRAKER:靈異現象咧! 11/13 00:03