Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Excel Problem

  • Please log in to reply



    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!

  • 0





  • Member
  • PipPip
  • 13 posts

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

  • 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