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