简体   繁体   中英

How to activate a specific worksheet in different worksheet in Excel

In a sub i am parsing activesheet and creating a new sheet(in a new workbook), After completion of this sub i need to activate the old sheet again So i created

Dim sourceSheet As Worksheet
Set sourceSheet = ActiveSheet
Analysis(sourceSheet)

In the next sub that will process this sheet, i sent the sourceSheet as variable

Public Sub Analysis(sourceSheet As Worksheet)
Set ActiveSheet = sourceSheet

It throws runtime error 438

How can i make the old sheet as active again? after creating new workbook using the parent sub

I don't believe you can actually set ActiveWorksheet , as that is read-only.

I think instead of:

Set ActiveSheet = sourceSheet

You want:

sourceSheet.Activate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM