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

2023-04-12 08:17:21   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《Excel VBA根据Sheet2中的表格数据处理Sheet1中的数据》,欢迎阅读!
数据处理,表格,根据,数据,Sheet2

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.wddqxz.cn/0839f6950a1c59eef8c75fbfc77da26924c5965b.html

相关推荐