ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Dynamic Sorting (https://www.excelbanter.com/excel-discussion-misc-queries/58713-dynamic-sorting.html)

Dr. Sachin Wagh

Dynamic Sorting
 
Sheet 2 has 20 rows (Column 1 - Heading & Column 2 - Total). This is linked
to Sheet 1 (thru vlookup).
I need to have these 20 rows sorted (Cloumn 2) in ascending manner, as the
figures of sheet 1 are changed. Is that possible?
--
Dr. Sachin Wagh
MBBS, DHA, DPH

Bob Phillips

Dynamic Sorting
 
Select the sheet2 worksheet, and then add this code

Option Explicit

Private Sub Worksheet_Calculate()

Me.Range("A1:B20").Sort key1:=Me.Range("B1"), header:=xlYes

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dr. Sachin Wagh" wrote in message
...
Sheet 2 has 20 rows (Column 1 - Heading & Column 2 - Total). This is

linked
to Sheet 1 (thru vlookup).
I need to have these 20 rows sorted (Cloumn 2) in ascending manner, as the
figures of sheet 1 are changed. Is that possible?
--
Dr. Sachin Wagh
MBBS, DHA, DPH




Dr. Sachin Wagh

Dynamic Sorting
 
Works wonders, Thanx a Ton

--
Dr. Sachin Wagh
MBBS, DHA, DPH


"Bob Phillips" wrote:

Select the sheet2 worksheet, and then add this code

Option Explicit

Private Sub Worksheet_Calculate()

Me.Range("A1:B20").Sort key1:=Me.Range("B1"), header:=xlYes

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dr. Sachin Wagh" wrote in message
...
Sheet 2 has 20 rows (Column 1 - Heading & Column 2 - Total). This is

linked
to Sheet 1 (thru vlookup).
I need to have these 20 rows sorted (Cloumn 2) in ascending manner, as the
figures of sheet 1 are changed. Is that possible?
--
Dr. Sachin Wagh
MBBS, DHA, DPH






All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com