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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,701
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
 

mtawheed

New Member
Joined
Mar 24, 2005
Messages
16
thank you, and sorry for not clarifying, you got what I really needed, many thanks
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,120
Messages
5,857,494
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

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
Top