By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

Easy Problem

P: 2
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.

A B
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.

Thanks,
Fisticuffs
Oct 30 '06 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,892
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

P: 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.

Fisticuffs
Oct 30 '06 #3

Expert 100+
P: 1,892
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.

HTH,
AricC
Oct 30 '06 #4

Post your reply

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