vba代码可根据每次运行的宏来更新状态

时间:2019-01-21 07:31:31

标签: excel

我有3个宏

  • 宏1用于最终输入表
  • 用于处理1张纸的宏2
  • 图纸3的宏

是否可以在宏1完成时更新状态表单元格B2中的单元格,然后基于B2的宏2将启动,一旦宏2完成,它将更新B3,基于宏B3的值将运行并宏3完成后,它将更新B4。

有可能吗?

我可以基于特定单元格中的值更改来运行宏,但是在宏运行完成后如何更新单元格?

Sub lastRow()

Dim wsS1 As Worksheet 'Sheet1
Dim wsS2 As Worksheet 'sheet2
Dim wsS3 As Worksheet 'sheet3

Dim lastR As Long, lastC As Long

Set wsS1 = Sheets("Input")
Set wsS2 = Sheets("Final Input")
Set wsS2 = Sheets("Status")

With wsS1
lastR = .Range("A" & .Rows.Count).End(xlUp).Row
End With

With wsS2
lastC = .Cells(3, Columns.Count).End(xlToLeft).Column
Range(.Cells(3, 1).Address, .Cells(3, lastC).Address).AutoFill 
 Destination:=Range(.Cells(3, 1).Address, .Cells(lastR, lastC).Address)

  With wsS3
 .Range ("B2" = completed)



End With
End Sub

2 个答案:

答案 0 :(得分:0)

['', '', '331', '67cf', '34b', '38f', '...', '517', '48f', 
         '331', '67cf', '34b', '38f', '...', '517', '48f']

答案 1 :(得分:0)

您只需将其添加到代码中,状态表就会针对第一个宏进行更新

wsS3.Range("B2").Value = "complete"