Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions


Upload your resume securely at https://www.dwsimpson.com
to be contacted when new jobs meet your skills and objectives.


View Poll Results: What is the best way to learn VBA?
Book 107 36.27%
Help 48 16.27%
Internet 147 49.83%
Macro Recorder 112 37.97%
Multiple Choice Poll. Voters: 295. You may not vote on this poll

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2006, 04:26 PM
Bama Gambler's Avatar
Bama Gambler Bama Gambler is offline
James Washer / Notes Contributor
SOA
 
Join Date: Jan 2002
Location: B'ham, AL
Posts: 17,181
Default Best way to learn VBA.

I'll rank my choices.

1. Good book. Any of the VBA books by Walkebach will do. This will help you write clean, readable code.

2. VBA Help files. Type what you want to do in help. They have some good examples.

3. Internet. Google it or post your question on a discussion board.

Avoid the macro recorder until you have honed your skills. It writes sloppy code and there is no macro recorder in Access.
__________________

We help people pass actuarial exams.

Follow us on Twitter, Facebook, and LinkedIn.

Reply With Quote
  #2  
Old 08-09-2006, 05:49 PM
Bama Gambler's Avatar
Bama Gambler Bama Gambler is offline
James Washer / Notes Contributor
SOA
 
Join Date: Jan 2002
Location: B'ham, AL
Posts: 17,181
Default

For those voting for macro recorder, can you say why you believe it's a good way to LEARN vba? I agree it's a good tool for those who already have a good foundation in vba, but to use it as a learning tool is just not smart IMO.

For example, I couldn't find how to change the datasource from the Object Browser or help files, but a quick record of creating a pivot table lead me to the solution.
__________________

We help people pass actuarial exams.

Follow us on Twitter, Facebook, and LinkedIn.

Reply With Quote
  #3  
Old 08-09-2006, 05:54 PM
Bama Gambler's Avatar
Bama Gambler Bama Gambler is offline
James Washer / Notes Contributor
SOA
 
Join Date: Jan 2002
Location: B'ham, AL
Posts: 17,181
Default

For example, if someone was to learn using the macro recorder then .Select would be all throughout their code. They wouldn't learn how to declare variables, create functions, or useful things like Cells(row, column). I could go on and on.
__________________

We help people pass actuarial exams.

Follow us on Twitter, Facebook, and LinkedIn.

Reply With Quote
  #4  
Old 08-09-2006, 06:36 PM
2.718281828's Avatar
2.718281828 2.718281828 is offline
Member
 
Join Date: May 2005
Posts: 176
Default

Another way to learn how to code is to have lots of deadlines at work. That way your livelihood (sp?) depends on figuring it out and fast.
Reply With Quote
  #5  
Old 08-09-2006, 07:33 PM
Brad Gile's Avatar
Brad Gile Brad Gile is offline
Member
CAS SOA AAA
 
Join Date: Sep 2001
Studying for whatever I feel like
College: Alumnus of Brown and UW-Madison
Posts: 11,341
Default

In addition, write a ton of experimental code to see
(1) what it does,
(2) what it does NOT do,
(3) what unexpected things it does.

Then find ways to modify that code to make it stable and practical, yet be self-explanatory as possible with good commentary where needed.


Brad
__________________
Brad Gile, FSA, MAAA
Affiliate Member of the CAS
Dedicated Retired Actuary

Spoiler:
Obama sucks and we all know it-TDA


Spoiler:

That's been the funniest subplot of this whole thing, the people on the left attacking this bill for not being even more of a steaming pile. - erosewater
Reply With Quote
  #6  
Old 08-09-2006, 08:40 PM
Bama Gambler's Avatar
Bama Gambler Bama Gambler is offline
James Washer / Notes Contributor
SOA
 
Join Date: Jan 2002
Location: B'ham, AL
Posts: 17,181
Default

whisper, why do you consider the macro recorder a good learning tool for vba? This is a sincere question. You've contributed to many a VBA questions over the years on this forum.
__________________

We help people pass actuarial exams.

Follow us on Twitter, Facebook, and LinkedIn.

Reply With Quote
  #7  
Old 08-09-2006, 08:41 PM
Griffin 1's Avatar
Griffin 1 Griffin 1 is offline
Member
 
Join Date: Sep 2001
Location: This is the worst kind of discrimination. The kind against me.
Favorite beer: Grizzly. No, wait - polar bears.
Posts: 10,485
Default

Quote:
Originally Posted by Bama Gambler View Post
For those voting for macro recorder, can you say why you believe it's a good way to LEARN vba? I agree it's a good tool for those who already have a good foundation in vba, but to use it as a learning tool is just not smart IMO.
Well thanks for asking! If you know how to program, then it's a good tool. If you don't know how to program, it's not. Programming is not something you learn all over again with each new language or software. As I said in the other thread, Actuaries are supposed to be smart. That means they can figure things out.

No one has said you should record a macro and leave it at that. What they (or at least I) have said is that it often gives you a good place to start. A person who knows his or her way around Excel and is smart enough to be an Actuary who sees:
Code:
    Range("A1:A10").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
        SkipBlanks:=False, Transpose:=False
can probably figure it out. You should give people more credit than what you do.

As for the lack of a recorder in Access, the any VBA you learn [b]will[/i] transfer, regardless of how you aquired the knowledge. And since Actuaries tend to spend more time in Excel than they do Access, they will also tend to learn their VBA in Excel first. So it's not usually going to be a problem.
__________________
I've never heard of such a brutal and shocking injustice that I cared so little about.
Reply With Quote
  #8  
Old 08-09-2006, 09:00 PM
whisper's Avatar
whisper whisper is offline
Member
CAS AAA
 
Join Date: Jan 2002
Location: Chicago
Favorite beer: Hefewizen
Posts: 33,822
Default

Quote:
Originally Posted by Bama Gambler View Post
whisper, why do you consider the macro recorder a good learning tool for vba? This is a sincere question. You've contributed to many a VBA questions over the years on this forum.
The recorder is a two edged sword. It is very verbose. So, it needs to be edited to be useable. On the other hand, it is so verbose it can show the student all the other things possible.

I've actually used the recorder recently to try to figure out how to do something because I knew the recorder was so verbose that somewhere in the code it had what I wanted, I just had to read it and figure out what that one thing was.
Reply With Quote
  #9  
Old 08-09-2006, 09:15 PM
Griffin 1's Avatar
Griffin 1 Griffin 1 is offline
Member
 
Join Date: Sep 2001
Location: This is the worst kind of discrimination. The kind against me.
Favorite beer: Grizzly. No, wait - polar bears.
Posts: 10,485
Default

Quote:
Originally Posted by Bama Gambler View Post
For example, if someone was to learn using the macro recorder then .Select would be all throughout their code. They wouldn't learn how to declare variables, create functions, or useful things like Cells(row, column). I could go on and on.
That's where the "Actuaries are smart" part comes in. When has anyone ever suggested that you're finished when you hit "Stop Recording"?
__________________
I've never heard of such a brutal and shocking injustice that I cared so little about.
Reply With Quote
  #10  
Old 08-09-2006, 10:44 PM
Bama Gambler's Avatar
Bama Gambler Bama Gambler is offline
James Washer / Notes Contributor
SOA
 
Join Date: Jan 2002
Location: B'ham, AL
Posts: 17,181
Default

Quote:
Originally Posted by Griffin 1 View Post
That's where the "Actuaries are smart" part comes in. When has anyone ever suggested that you're finished when you hit "Stop Recording"?
I know actuaries are smart, but you'll never find Cells(r,c) in a recorded macro. I use that more than anything else and I learned it from a book (or online, can't remember which). Most of the stuff I use (with regard to the Excel specific VBA) on a regular basis I got from a book, help or the internet. Only things I've gotten from the macro recorder are very obsure things (like the pivot table thing) and formatting stuff. So 90% of the stuff I use I didn't (and can't) learn from macro recorder. The other 10% isn't needed by someone trying to LEARN vba. So I'd tell that person to get a good foundation before using the macro recorder, even if they are an advanced programmer.

When I first started VBA programming I was already pretty good in VB. I used the macro recorder to learn the excel specific stuff at first and I was writing code like:

dim i as integer

for i = 1 to 10
range("A"&i).select
activecell.value = i
next i

Columns were of course a *****.

I knew there had to be a better way so I bought a book and of course started writing better code immediately. Can you learn from the macro recorder? Of course. Is is the BEST way to learn? Hell no. Even for the best programmer in the world, he'd be better off scanning a book, then recording stuff.
__________________

We help people pass actuarial exams.

Follow us on Twitter, Facebook, and LinkedIn.

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 04:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 1.26233 seconds with 10 queries