View Single Post
 
Old 06-20-2014, 09:51 PM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Time to point you to some documentation:

1) An on-line reference to VBA for 2010: http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx. This tells you most of what you need to know about the features of the VBA language itself: the statements, the data types etc. For instance, you mentioned the issue of what counts as a valid variable name in VBA; there's a definition at http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx (first character must be a letter, no more than 255 chars long, a list of characters you may not use in a variable name etc). You'll probably have some trouble finding what you want to know at first, so don't stop asking; but bookmark some of your favorite pages and come back to read more from time to time.

2) An on-line reference to the Excel object model: http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx. Ok, "object model" probably doesn't mean anything to you yet, but it's all about the Excel objects that you can manipulate with VBA, and each object's properties, methods, events and other such things that you haven't learned about yet.

The difference is this: In #1, about the VBA language, you learn general concepts. But the VBA language can be used to manipulate many different applications, not just Excel but also Access, Word, Outlook and lots of other objects that have nothing to do with MS Office. When you're programming for Excel you have to know about worksheets, rows, fonts, formulae, borders, conditional formatting and so forth; that's all described in #2. When you're programming for Word, you have no need to understand worksheets but you do need to understand paragraphs. Excel, Word and Outlook all have something called "styles", but they're different in each one—a different team of programmers designed styles in each, so knowing how to manipulate styles in Excel won't help you to do the same in Word. The VBA language is the same, but the objects are different.

(You don't have to learn to program in Word, presumably; I'm not trying to confuse the issue, only to explain the difference between the VBA language and the Excel objects.)

3) Some help (I don't think much of it) for using the VBE Editor itself: http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx. The documentation may be more help to you than it is to me, but however you learn it the editor itself, where you type in the code, can be a tremendous help to you in debugging it. I haven't mentioned it before, but it's time. If you don't already know how to (for example) step through your program one statement at a time, and stop at any point and look to see what value is in rz, or what font is being used in cell E3, it's well worth knowing.

From now on when we talk about how to use the Group method, use the For...Next statement or write a MsgBox announcement to yourself, I'll start pointing to the documentation so you can read about it yourself instead of having to be satisfied with the little bit I tell you.

---

TextToColumns is (in my opinion) pretty complex. I've done it a few times in VBA, but I don't do it cheerfully. You can definitely learn it; but I'll be happier teaching you simpler things at first, until you're more comfortable with some other concepts. For example you wonder about the difference between a subroutine, a function, a method, and object and so on; for my money that's part of the foundation that you should lay before getting very far.

I am NOT saying you must learn all the basic stuff before learning anything more advanced; that's one of the most boring ways to learn anything I've encountered. But if you're trusting me for your education (and you needn't, and eventually shouldn't—I mean, eventually you should either insist I answer your questions or go looking around for other help), I'd wait on TextToColumns a while longer, do it manually for now.

What I'd like to do next is a) answer some of the questions you've already asked, about code you mentioned below and about anything new you write (whether it works or not); b) make sure you get the grouping finished; and c) show you some additional features of the VBA Editor, such as the Watch Window.
Reply With Quote