Excel VBA根据Sheet2中的表格数据处理Sheet1中的数据

时间:2023-04-12 08:17:21 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Attribute VB_Name = "模块2"

Sub dataprocess()

'

'dataprocessing

'

Dim newcase As Integer

Dim oldcase As Integer

Dim clscase As Integer

Dim yescase As Integer

Dim todcase As Integer

Dim Sht1 As Worksheet

Set Sht1 = Worksheets("today")

Dim Sht2 As Worksheet

Set Sht2 = Worksheets("yesteday")

yescase = 0

Do

yescase = yescase + 1

Loop Until Sht2.Cells(yescase + 2, 1) = ""

todcase = 0

Do

todcase = todcase + 1

Loop Until Sht1.Cells(todcase + 2, 1) = ""

oldcase = 0

i = 2

Do

j = 2

Do

If Sht1.Cells(i, 1) = Sht2.Cells(j, 1) Then

oldcase = oldcase + 1

'dataprocessing

Sht1.Cells(i, 8) = Sht2.Cells(j, 8)

Sht1.Cells(i, 11) = Sht2.Cells(j, 11)

Sht1.Cells(i, 1).Interior.ColorIndex = 39

'end_dataprocessing

Exit Do

End If

j = j + 1

Loop Until Sht2.Cells(j, 1) = ""

i = i + 1

Loop Until Sht1.Cells(i, 1) = ""

newcase = todcase - oldcase

clscase = yescase - oldcase

MsgBox "Dataprocessing Completed" & vbCrLf & _

"colse case num:" & clscase & vbCrLf & _

"old case num:" & oldcase & vbCrLf & _

"new case num:" & newcase

End Sub

本文来源:https://www.wddqw.com/doc/0839f6950a1c59eef8c75fbfc77da26924c5965b.html