excel表,Alt+F11調用出vb語言處理excel表內容,很方便


Alt + F11調出來

 

然后可以右鍵插入窗體

 

Public Sub 處理數據_Click()

    Sheets(1).Columns(4).ColumnWidth = 12
    Sheets(1).Columns(5).ColumnWidth = 12
    
    Dim i, j As Integer
    Dim nRow As Integer
    nRow = ActiveSheet.[A65536].End(xlUp).Row
    Debug.Print nRow
    
    Dim nRowCount As Integer
    nRowCount = 1
    Dim strFlag1 As String
    Dim strFlag2 As String
    For i = 1 To nRow
        strFlag1 = Right(Sheets(1).Cells(i, 1), 3)
        strFlag2 = Left(Sheets(1).Cells(i, 1), 3)
        For j = 1 To nRow
            If (strFlag1 = Left(Sheets(1).Cells(j, 1), 3) And strFlag2 <> Right(Sheets(1).Cells(j, 1), 3)) Then
                Sheets(1).Cells(nRowCount, 4) = Sheets(1).Cells(i, 1)
                Sheets(1).Cells(nRowCount, 5) = Sheets(1).Cells(j, 1)
                nRowCount = nRowCount + 1
            End If
        Next j
    Next i
End Sub

  意思是處理這個sheet表1列,將處理結果,寫入,第4列和第5列

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM