Worsheet Activate code

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi,

I'm trying to figure out a worksheet activate event code that would insert the text "Total" to the column B below the last data row. And also insert the formula =SUBTOTAL(109,T17:T1048572) to column T below the last data row.

Any help on this would be kindly appreciated.

Thanks in advance.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Here is the code I've got so far. The code inserts the text "Total" when the code is placed in a standard module. But It is not working when placed in a worksheet module.

What have I done wrong here?
Code:
Private Sub Worksheet_Activate()
    Dim m As Long
    With Worksheets("MySheet")
        m = .Cells(.Rows.Count, 2).End(xlUp).Row
        If Not .Cells(m, 4) = "Total" Then
            .Cells(m + 1, 4) = "Total"
            .Cells(m + 1, 4).Font.Bold = True
        End If
    End With
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top