select question

mtawheed

New Member
Joined
Mar 24, 2005
Messages
16
I have the following macro, works great in my sheet, but you may notice that it hides certain rows based on a calculated value, the problem is that the selected cells after the macro is executed are the hidden or the displayed cells, I don't want this to hapen, I want the selecte cell to be the one that I'm changing, not to jump to the hidden rows... hope you got me

Private Sub Worksheet_Calculate()

If Range("L73").Value > Range("o55").Value Then
Application.EnableEvents = False
With Range("AI3:AI72")
.Value = Range("AF3:AF72").Value
.Sort Key1:=Range("AI3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = False
Application.EnableEvents = True
Else
Application.EnableEvents = False
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = True
Application.EnableEvents = True
End If
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Your description is not that clear, ( as you contradict yourself : "the selected cells ... are the hidden or the displayed cells", well, you can't have it both ways! ), but looking at your code instead I notice that you select certain rows to be hidden ... change your code to hide the rows without selecting them:
Sheets("DM1").Rows("75:85").EntireRow.Hidden = False
 
Upvote 0

Forum statistics

Threads
1,214,325
Messages
6,118,892
Members
448,854
Latest member
Eduard_Stoo

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