activation macro only works with F8

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
821
Office Version
  1. 365
Platform
  1. Windows
Hi

I have an activation macro for a sheet in a workbook I want it to find the date and scroll to the top of the screen
VBA Code:
Private Sub Worksheet_activate()
Set C = Range("A:A").Find(Date)
If Not C Is Nothing Then C.Select
ActiveWindow.ScrollRow = ActiveCell.Row
ActiveWindow.SmallScroll
End Sub
The macro finds the date ( the cursor goes to it) but doesn’t scroll to the top. I also have Conditional Format change the font to red. that works.
If I run the macro using F8 it works fine
I inserted a shape on the page and assigned a macro to it coping the activation macro and it works
VBA Code:
Sub opening()
Set C = Range("A:A").Find(Date)
If Not C Is Nothing Then C.Select
ActiveWindow.ScrollRow = ActiveCell.Row
ActiveWindow.SmallScroll
End Sub
I save the sheet and close using a macro that first goes to A1. I use the save and close macro for all sheets in excel

I use the same activation macro in other workbooks and worksheets, and it works fine

Any idea what I should look for?



mike
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try:
VBA Code:
Private Sub Worksheet_activate()
    Set C = Range("A:A").Find(Date)
    If Not C Is Nothing Then C.Select
    Application.Goto ActiveCell.EntireRow, True
End Sub
 
Upvote 0
Solution
Hi mumps
I copied your macro, replacing mine and all it does is highlight the entire row

mike
 
Upvote 0
I want it to find the date and scroll to the top of the screen
I believe that the macro does what you requested. If you don't want to select the entire row, what do you want it to do?
 
Upvote 0
Hi mumps
When the macro finds the date, I want it to move the entire row to the top.
when I used your macro it only highlighed the whole row.
it didn't move it to the top
I also
created a new worksheet in a new workbook and put in a few dates in A:A
I used your macro on opening it
It did move the entire row to the top
but the entire row was highlighted which i think i can change
I also put in my original macro and it work
but its weird that my macro works in other sheets and won't do a thing in this sheet
and it's weird that your macro won't work in this sheet. but will work in a new sheet.
What I'm going to do make a new workbook/worksheet using my data and see what happens
I'll try yours and mine
Oh, I also rebooted the cpu after I added your macro. I can't thing of anything else to try
Thanks for taking the time to help me

mike
 
Upvote 0
I tested the macro on a dummy sheet and it worked properly. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of the problem sheet. Alternately, you could upload a copy of your file (de-sensitized if necessary) to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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