Can I run Visual Basic procedure using Excel Visual Basic editor?

J

john.jacobs71

I am trying to build a very simple loop to compare columns of data in excel.
I am not an experienced programmer but I am trying to learn enough to write
this code. The problem is, none of the examples in online tutorials match
the software menu options in the Visual Basic Editor I open through the
tools/macro submenu. For example, the tutorial may recommend opening the
file menu and selecting new program, but in the tutorial this option does not
even exist. Furthermore, any code I have attempted to write, even when it is
directly copied from very basic examples, crashes from syntax errors. Are
there tutorials that match the Excel module of VB so that I can get started??
 
H

Harald Staff

Hi

Your tutorials are probably for Visual Basic, which is a standalone
programming suite where you can write standalone programs and other things,
or they are for Visual Basic.Net , which is a newer version of the same.
Excel and the rest of Office use a thing called Visual Basic for
Applications (aka VBA). VBA is mostly used to program and control the Office
applications, so the user interface and the available objects are different.

Languages are either the same (VB and VBA) or pretty similar (VB.Net) so
once you learn the basics, you can implement any code in any of these
applications. Excel is a great place to start programming, but I'd recommend
an Excel programming book for a start:
http://www.j-walk.com/ss/books/bookxl27.htm

HTH. Best wishes Harald
 
R

Rob

Hi John,

I don't have the knowledge to explain why you have so much trouble with
"crashes from syntax errors", but maybe if you quote a specific example
someone can help pinpoint the problem quicker.Just out of curiousity, have
you tried recording your actions using the macro recorder (excel - tools -
macro - record new macro) & then modifying the resulting code in the VBE?
I'm just learning what Excel can do myself, but I strongly believe that one
of the best ways to learn is to look at examples (eg Google "compare lists"
or "find/count/list duplicates" etc) & modify/copy the info - whether it's
macro or formula based.
A couple of pages I have found useful for techniques to use when comparing
columns of data are:
http://www.mvps.org/dmcritchie/excel/duplicates.htm
http://www.cpearson.com/excel/duplicat.htm (a link on above page)
NB, Dave Hawley (among others, is very wary of using loops), eg
http://www.ozgrid.com/VBA/VBALoops.htm

hth,
regards
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top