全民一起VBA基礎篇第五課 字串,邏輯運算,除錯

2021-10-01 19:07:00 字數 1323 閱讀 5136

單擊語句左側,得到乙個紅色的點

按f8進入除錯

除錯->新增監視

除錯完後去掉所有斷點

除錯->清除所有斷點

與或非的表示是 and or not 注意區分

沒有括號,先not, and 後or

if age<30 and field = 「數學」 or field=「物理」 then

左右兩邊都要完整

if cells(1,1)=「rmb」 or cells(1,1)=「人民幣」 then

if not age >16 then

兩個字串之間的連線 用 & 符號左右需要各空出一格

例如,需要知道高亮和加粗是怎樣的

可以如下操作

開發工具->錄製巨集

選中任一單元格,加粗,改色

停止錄製

sub 巨集3()

with selection.font

.color=-

16776961

.tintandshade =

0end

with

selection.font.bold =

true

endsub

然後得到上述,進行修改

可以得到下面的**

option explicit

sub highlight(

)dim i as

integer

for i =

101to

1step-1

'逆序判斷比較科學

if cells(i,2)

>

500then

'判斷單元格的數值

cells(i,

2).font.bold =

true

'用來加粗

with cells(i,

2).font '用來改字型顏色

.color=-

16776961

.tintandshade =

0end

with

endif

next i

endsub

就可以挑出超過500的,然後加粗變紅

如果想得到刪除啊,換行之類的,都可以錄製巨集來獲取vba**,略微修改即可自己用

全民一起VBA基礎篇第三課 變數與常量

sub 加法變數 i cells 2,2 cells i,9 cells i,5 cells i,7 利用變數來控制 endsub 計算半徑,面積和體積 sub 求面積和體積 radius cells 4,3 r radius square 4 r r 3cells 4,4 square volum...

Autocad二次開發vba教程第五課

第五課 畫函式曲線 下面是原始碼 sub myl dim p 0 to 49 as double 定義點座標 dim myl as object 定義引用曲線物件變數 co 15 定義顏色 for a 0.01 to 1 step 0.02 開始迴圈畫拋物線 for i 24 to 24 step ...

C語言第五課 字串的

字串的處理 字串賦值 strcpy 目的字串陣列名 源字串陣列名 char arr1 10 i love u char arr2 10 guo guo strcpy arr1 arr2 把 arr2中的內容拷貝到 arr1中 注意 目的字串 arr1 必須有足夠長的長度,否則不能全部裝入所複製的字串...