467,151 Members | 925 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,151 developers. It's quick & easy.

Easy Problem

To the VB universe,

Although I'm familiar with C++, it has been a while since I've done any programming and am having problems translating that knowledge to Visual Basic.

I'm trying to create a macro in Excel that will automatically sort a file that is formatted in two columns as shown below.

John Smith Jane Rib
John Smith Sam Smith
John Smith Dirt McGerk
Julian Lennon Yoko Ono
Julian Lennon Paul McCartney
Sampson Simpson Dirk Diggler

into a format like:

John Smith
Jane Rib
Sam Smith
Dirt McGerk

Julian Lennon
Yoko Ono
Paul McCartney

Sampson Simpson
Dirk Diggler

I would appreciate any advice/help/direction that anyone can provide.

Oct 30 '06 #1
  • viewed: 1022
3 Replies
Expert 1GB
Are you trying to do this in VB or in Excel? If in Excel why don't you just record a macro?
Oct 30 '06 #2
I'm trying to do this in excel.

Why don't I record a macro? Good question.(What's the benefits of a macro vs. VB code?) Would that be easier? If so, let me know the basics and I'll run with it.

The file that I'll be formatting will be a different number of names each week, if that means anything.

Oct 30 '06 #3
Expert 1GB
Got this from MSDN blog:

Macros vs. VBA
As many people have pointed out, macros do not offer the same range of functionality that VBA does. It's kind of interesting that some people even think that Macros were some sort of pre-VBA functionality that Access had. This is actually false - both macros and VBA were introduced in the same Access version (do you know which?).

Macros were thought as kind of a more structured, entry-level way to code in Access, while VBA had the steeper learning curve but had the full range of functionality on its hands.

So, why should you use macros?

I'm not even going to make the cheesy comment that anyone that ever used the DoCmd functions (e.g. DoCmd.OpenForm) were really using macro actions. Because, you know, that's actually not 100% true: the DoCmd commands were exposed at the same time to macros and VBA - they are different entry points to the same infrastructure.

I think the answer lies in the corollary: Don't Write Code Unless You Absolutely Must. And that is coming from someone that writes code pretty much all day long.

I believe that there is a use for macros (besides the obvious cases where you don't have an option, such as the AutoExec macro), and that use may very well be when you need to do something very simple (programmatically speaking, e.g. open a form) but you don't want to have the IT police freak out when they see VBA code.

I would do a macro if you can, it will save you some time unless your a VBA expert and could write the code quickly.

Oct 30 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Martin Bootsma | last post: by
9 posts views Thread by thetechturf.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.