日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

EXCEL VB简单使用

發布時間:2023/12/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 EXCEL VB简单使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Excel啟用vb編輯,要在選項中自定義功能區把開發工具加上。
上次簡單使用vb處理一些excel數據,現學了一下。把代碼存著,以后備用。

' 定義按鈕點擊事件 Private Sub CommandButton1_Click()' 選擇當前工作簿1Worksheets(1).Select' 如果處理多數據時,就false掉excel的實時更新Application.ScreenUpdating = False' 定義變量int型Dim line As IntegerDim col As Integer' 賦值變量line = 1col = 2Dim high As Integer' 獲取表格最大行數'high = Application.WorksheetFunction.CountA(Columns(1).EntireColumn)' 循環遍歷從1到1000For i = 1 To 1000 'Step 3' 定義字符串Dim str As String' 定義數組Dim arr1() As String'Dim arr2() As StringDim arrLength1 As Integer'Dim arrLength2 As Integer' 獲取表格值,并對表格賦值'Cells(line, 2).Value = Cells(i, 1)str = Cells(i, 1)' if then else endif判斷語句If str = "" Thenline = line + 1col = 2Else' 劃分字符串arr1() = Split(str, " ")' 獲取字符串長度arrLength1 = UBound(arr1)For j = 0 To 1 'arrLength1' 表格賦值Cells(line, col).Value = arr1(j)col = col + 1' For循環結束標志NextCells(line, col).Value = "v"col = col + 1Cells(line, col).Value = "-"col = col + 1End If'arr1() = Split(str, " ")'arrLength1 = UBound(arr1)'If 0 = i Mod 2 Then' For j = 0 To 1 'arrLength1' Cells(line, col).Value = arr1(j)' col = col + 1' Next'End If'str = Cells(i + 2, 1)'arr2() = Split(str, " ")'arrLength2 = UBound(arr2)'If 0 = i Mod 2 Then' For m = 0 To arrLength2' Cells(line, 2 + arrLength1 + 1 + m + 1).Value = arr2(m)' Next'End If'Cells(line, 2 + arrLength1 + 1 + arrLength2 + 1 + 1).Value = Cells(i + 3, 1)'line = line + 1' For循環結束標志 Next' 當所有數據處理完后,使excel刷新表格Application.ScreenUpdating = True' 函數結束 End Sub

總結

以上是生活随笔為你收集整理的EXCEL VB简单使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。