Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Excel Problem


  • Please log in to reply

#1
Alexchar

Alexchar

    New Member

  • Member
  • Pip
  • 1 posts
Hi everyone!

I have a excel spread sheet, which I need to write a macro. After the information has been entered, I need the data (zip codes) in order. My question is how do I write a macro that will do a comparison between zip codes, and then place them in descending order. Thanks in advance!

Joseph
  • 0

Advertisements


#2
KingMartin

KingMartin

    Member

  • Member
  • PipPip
  • 13 posts
Hello,

you'll need to call the sort method of a range object.

Place this into the Sheet's class module (not a normal module).

Works for A column, if your ZIPS are in a different column, adapt the code (change A to your column)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rg As Range
Set rg = [A:A]
If Intersect(rg, Target) Is Nothing Then Exit Sub
Range("A1:A" & [a65536].End(3).Row).Sort [A1], Header:=xlYes
End Sub

Martin
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP