मुख्य सामग्री पर जाएं

Excel में मान के आधार पर कॉलम को स्वचालित रूप से कैसे क्रमबद्ध करें?

लेखक: केली अंतिम संशोधित: 2022-09-22

उदाहरण के लिए, आपके पास एक खरीद तालिका है जैसा कि नीचे स्क्रीनशॉट में दिखाया गया है। अब आप चाहते हैं कि जब आप इस कॉलम में नए नंबर/कीमतें दर्ज करें तो मूल्य कॉलम स्वचालित रूप से क्रमबद्ध हो जाए, तो आप इसे कैसे हल कर सकते हैं? यहां मैं एक्सेल में मूल्य के आधार पर एक विशिष्ट कॉलम को स्वचालित रूप से क्रमबद्ध करने में आपकी सहायता के लिए एक वीबीए मैक्रो प्रस्तुत करता हूं।

वीबीए के साथ मूल्य के आधार पर कॉलम को स्वचालित रूप से क्रमबद्ध करें


वीबीए के साथ मूल्य के आधार पर कॉलम को स्वचालित रूप से क्रमबद्ध करें

जैसे ही आप Excel में कॉलम में नया डेटा दर्ज करेंगे या मान बदलेंगे, यह VBA मैक्रो स्वचालित रूप से एक विशिष्ट कॉलम में सभी डेटा को सॉर्ट कर देगा।

1. वर्तमान शीट नाम पर राइट क्लिक करें शीट टैब बार, और उसके बाद क्लिक करें कोड देखें राइट-क्लिक मेनू से।

2. एप्लिकेशन के लिए खुलने वाले Microsoft Visual Basic संवाद बॉक्स में, निम्नलिखित VBA मैक्रो कोड को शुरुआती विंडो में चिपकाएँ।

वीबीए: एक्सेल में ऑटो सॉर्ट कॉलम

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("B:B")) Is Nothing Then
Range("B1").Sort Key1:=Range("B2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

नोट:
1) उपरोक्त वीबीए कोड में, बी:बी इसका मतलब है कि यह कॉलम बी को स्वचालित रूप से सॉर्ट करेगा, B1 कॉलम बी में पहला सेल है, B2 कॉलम बी में दूसरा सेल है, और आप अपनी आवश्यकताओं के आधार पर उन्हें बदल सकते हैं।
2) स्निपेट शीर्षलेख:=xlहां 5वीं पंक्ति एक्सेल को बताती है कि आप जिस रेंज को सॉर्ट करेंगे, उसमें एक हेडर है, ताकि सॉर्ट करते समय रेंज की पहली पंक्ति शामिल न हो। यदि कोई हेडर नहीं है तो कृपया इसे बदल दें शीर्षलेख:=xlNo; और बदलो कुंजी1:=रेंज('बी2') चौथी पंक्ति में कुंजी1:=रेंज('बी1').

3. फिर वर्कशीट पर वापस जाएं, जब आप मूल्य कॉलम में एक नया नंबर दर्ज करते हैं या किसी मौजूदा कीमतों को संशोधित करते हैं, तो मूल्य कॉलम स्वचालित रूप से आरोही क्रम में क्रमबद्ध हो जाएगा।

नोट: जब आप मूल्य कॉलम में एक नया नंबर दर्ज करते हैं, तो आपको मूल नंबरों के नीचे पहले खाली सेल में नंबर दर्ज करना होगा। यदि नए दर्ज किए गए नंबर और मूल संख्याओं के साथ-साथ मूल संख्याओं के बीच रिक्त सेल हैं, तो यह कॉलम स्वचालित रूप से सॉर्ट नहीं किया जाएगा।


डेमो: एक्सेल में वीबीए के साथ मूल्य के आधार पर कॉलम को स्वचालित रूप से क्रमित करें


एक्सेल के लिए कुटूल: आपकी उंगलियों पर 300 से अधिक उपयोगी उपकरण! आज ही बिना किसी सुविधा सीमा के अपना 30-दिवसीय निःशुल्क परीक्षण प्रारंभ करें। अब डाउनलोड करें!

Excel में घटनाओं की आवृत्ति के आधार पर आसानी से क्रमबद्ध करें

एक्सेल के लिए कुटूल उन्नत सॉर्ट उपयोगिता एक्सेल में टेक्स्ट की लंबाई, अंतिम नाम, निरपेक्ष मान, आवृत्ति आदि के आधार पर डेटा को शीघ्रता से सॉर्ट करने का समर्थन करती है।


आवृत्ति के आधार पर विज्ञापन क्रमबद्ध करें 2

सर्वोत्तम कार्यालय उत्पादकता उपकरण

🤖 कुटूल्स एआई सहयोगी: निम्न के आधार पर डेटा विश्लेषण में क्रांति लाएं: बुद्धिमान निष्पादन   |  कोड जनरेट करें  |  कस्टम फ़ॉर्मूले बनाएं  |  डेटा का विश्लेषण करें और चार्ट बनाएं  |  कुटूल फ़ंक्शंस का आह्वान करें...
लोकप्रिय सुविधाएँ: डुप्लिकेट ढूंढें, हाइलाइट करें या पहचानें   |  रिक्त पंक्तियाँ हटाएँ   |  डेटा खोए बिना कॉलम या सेल को संयोजित करें   |   फॉर्मूला के बिना गोल ...
सुपर लुकअप: एकाधिक मानदंड VLookup    मल्टीपल वैल्यू वीलुकअप  |   अनेक शीटों में VLookup   |   फजी लुकअप ....
उन्नत ड्रॉप-डाउन सूची: शीघ्रता से ड्रॉप डाउन सूची बनाएं   |  आश्रित ड्रॉप डाउन सूची   |  बहु-चयन ड्रॉप डाउन सूची ....
स्तम्भ प्रबंधक: कॉलमों की एक विशिष्ट संख्या जोड़ें  |  कॉलम ले जाएँ  |  छिपे हुए कॉलम की दृश्यता स्थिति टॉगल करें  |  रेंज और कॉलम की तुलना करें ...
फीचर्ड फीचर्स: ग्रिड फोकस   |  डिजाइन देखें   |   बड़ा फॉर्मूला बार    कार्यपुस्तिका एवं शीट प्रबंधक   |  संसाधन लाइब्रेरी (ऑटो टेक्स्ट)   |  खजूर बीनने वाला   |  कार्यपत्रकों को संयोजित करें   |  एन्क्रिप्ट/डिक्रिप्ट सेल    सूची के अनुसार ईमेल भेजें   |  सुपर फ़िल्टर   |   विशेष फ़िल्टर (फ़िल्टर बोल्ड/इटैलिक/स्ट्राइकथ्रू...) ...
शीर्ष 15 टूलसेट12 टेक्स्ट टूल्स (पाठ जोड़ें, अक्षर हटाएँ, ...)   |   50 + चार्ट प्रकार (गैन्ट चार्ट, ...)   |   40+ प्रैक्टिकल सूत्र (जन्मदिन के आधार पर आयु की गणना करें, ...)   |   19 निवेशन टूल्स (QR कोड डालें, पथ से चित्र सम्मिलित करें, ...)   |   12 रूपांतरण टूल्स (शब्दों को संख्याएँ, मुद्रा रूपांतरण, ...)   |   7 विलय और विभाजन टूल्स (उन्नत संयोजन पंक्तियाँ, विभाजन कोशिकाओं, ...)   |   ... और अधिक

एक्सेल के लिए कुटूल के साथ अपने एक्सेल कौशल को सुपरचार्ज करें, और पहले जैसी दक्षता का अनुभव करें। एक्सेल के लिए कुटूल उत्पादकता बढ़ाने और समय बचाने के लिए 300 से अधिक उन्नत सुविधाएँ प्रदान करता है।  वह सुविधा प्राप्त करने के लिए यहां क्लिक करें जिसकी आपको सबसे अधिक आवश्यकता है...

Description


ऑफिस टैब ऑफिस में टैब्ड इंटरफ़ेस लाता है, और आपके काम को बहुत आसान बनाता है

  • Word, Excel, PowerPoint में टैब्ड संपादन और रीडिंग सक्षम करें, प्रकाशक, एक्सेस, विसियो और प्रोजेक्ट।
  • नई विंडो के बजाय एक ही विंडो के नए टैब में एकाधिक दस्तावेज़ खोलें और बनाएं।
  • आपकी उत्पादकता 50% बढ़ जाती है, और आपके लिए हर दिन सैकड़ों माउस क्लिक कम हो जाते हैं!
Comments (37)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
such a good information thanks a lot
This comment was minimized by the moderator on the site
Maravilhoso! Muito obrigada pela informação, amigo!
Rated 5 out of 5
This comment was minimized by the moderator on the site
I love this, but I'd like to know what I should do if I want it to be multiple different ranges in the same column. When I use the code above, it works for the first table that I have but the bottom two tables don't sort automatically. I tried changing the range, I also duplicated the code and changed the code to match the tables, but nothing is working.

For example:
Range("L8").Sort Key1:=Range("L37"),Range("L41").Sort Key1:=Range("L62") _

Or just duplicating the code like this:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("L:L")) Is Nothing Then
Range("L8").Sort Key1:=Range("L37"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("L:L")) Is Nothing Then
Range("L41").Sort Key1:=Range("L62"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("L:L")) Is Nothing Then
Range("L66").Sort Key1:=Range("L100"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

But then it will tell me that "Ambiguos name detected: Worksheet_Change" but it won't do that if I only have the code one. Would anyone be able to help me out?
Thank you!
This comment was minimized by the moderator on the site
Hi there,

You can use the vba below:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Not Intersect(Target, Range("K:K")) Is Nothing Then
        Range("K32:K36").Sort Key1:=Range("K32"), _
        Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom
        
        Range("K38:K42").Sort Key1:=Range("K38"), _
        Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom        

        Range("K44:K46").Sort Key1:=Range("K44"), _
        Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom
    End If
End Sub


Amanda
This comment was minimized by the moderator on the site
01. I have sorted on Name data in Excel Worksheet as Sheet1.
02. I want the Names that are repeated in New Worksheet as Sheet2.
This comment was minimized by the moderator on the site
Hallo
Ich habe folgenden Code, aber die Sortierung klappt leider nicht.
evtl nur eine kleine Anpassung, aber ich verzweifle hier seit Tagen.
Danke im voraus.


Sub Eindeutige_Daten()

Dim rng As Range
Dim InputRng As Range, OutRng As Range

Set dt = CreateObject("Scripting.Dictionary")

xTitleId = "Eindeutige Daten"

Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)

For Each rng In InputRng
If rng.Value <> "" Then
dt(rng.Value) = ""
End If
Next

OutRng.Range("A1").Resize(dt.Count) = Application.WorksheetFunction.Transpose(dt.Keys)

'** Zelladresse in Spalten- und Zeilenangabe trennen
Dim wert() As String
wert = Split(OutRng.Address, "$")

letztezeile = ActiveSheet.Cells(1048576, wert(1)).End(xlUp).Row

With ActiveWorksheet.Sort
.SetRange Range(OutRng & ":" & wert(1) & letztezeile)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Calculate

End Sub
This comment was minimized by the moderator on the site
Hi there,

Please debug the below snipt of your code and see if there is a problem.
With ActiveWorksheet.Sort
.SetRange Range(OutRng & ":" & wert(1) & letztezeile)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Remember to check the values you entered.
If there is still questions, please don't hesitate to ask me.

Amanda
This comment was minimized by the moderator on the site
Love it. Works for me.

But when I repeat the exact same steps at another Excel file, and enter a number in the colomn for it to autosort, Excel closes.
This comment was minimized by the moderator on the site
Hi,
This is extremely useful.
Is there a way to expand the formula to cover multiple columns? For example, to sort data based on values on first, column B, and then column C?I would really appreciate any solutions!
This comment was minimized by the moderator on the site
Amazing thanks!!!
This comment was minimized by the moderator on the site
So this seems to work when the data is manually entered but doesn't work when it is a table that repopulates from another file....is there any way to do that?
This comment was minimized by the moderator on the site
Hi, it arrange the entire row but I have some link on cells into specific folder which is left behind after sort.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations