Hi,
Please help me for sorting the range, i have applied the code but it is not working.
Regards
Sandeep Kumar
Hi,
Please help me for sorting the range, i have applied the code but it is not working.
Regards
Sandeep Kumar
How can we help without a sample of the data and the code you have used?
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
NB: as a Moderator, I never accept friendship requests.
Forum Rules (updated August 2023): please read them here.
Sir,
Please find enclosed the attached file as refer in above.
Regards
Sandeep Kumar
1) Replace
with![]()
sh.Range("Ac3", Range("Ac3").End(xlDown)).Sort Key1:=Range("AC3"), Order1:=xlAscending, Header:=xlNo
2) You can delete 2 lines that selects the range.![]()
sh.AutoFilter.Range.Sort sh.[ac3], 1, , , , , , 1
Thanks for the response.
But it is not working, may you please put it on file and send me the updated file.
Regards
Sandeep Kumar
"Not working" is explaining nothing.
How is it not working?
I'm out and not with my PC.
If you post your code after the change, I will see and if it is how I exactly suggested, I can not help you more.
Sub Auto_filter()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Main")
Dim dsh As Worksheet
Set dsh = ThisWorkbook.Sheets("Data")
dsh.UsedRange.Clear
sh.AutoFilterMode = False
'''''''' filter EMP - 1
sh.Range("2:2").Select
sh.Range("2:2").AutoFilter 28, "Delhi"
sh.UsedRange.Copy dsh.Range("A1")
sh.Range("aC3").Select
sh.Range("Ac3", Range("Ac3").End(xlDown)).Sort Key1:=Range("AC3"), Order1:=xlAscending, Header:=xlNo
dsh.Cells.Range("b2:BB10000").EntireColumn.AutoFit
sh.AutoFilterMode = False
End Sub
1)
Administrative Note:
Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
2)
No, that is not what I suggested
Read my post carefully.
I apologize for the same.
Hi Jindon,
Here, please find the code in below.
Sub Auto_filter()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Main")
Dim dsh As Worksheet
Set dsh = ThisWorkbook.Sheets("Data")
dsh.UsedRange.Clear
sh.AutoFilterMode = False
'''''''' filter EMP - 1
sh.Range("2:2").Select
sh.Range("2:2").AutoFilter 28, "Delhi"
sh.UsedRange.Copy dsh.Range("A1")
sh.Range("aC3").Select
sh.Range("Ac3", Range("Ac3").End(xlDown)).Sort Key1:=Range("AC3"), Order1:=xlAscending, Header:=xlNo
dsh.Cells.Range("b2:BB10000").EntireColumn.AutoFit
sh.AutoFilterMode = False
End Sub
Regards
Sandeep Kumar
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks