Thread: Basic Syntax
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Basic Syntax

really no need to select most of the time, but here it is

Worksheets("data").Range("A24", Range("A24").End(xlDown)).Select

--


Gary


"Nick_F" wrote in message
ups.com...
I have recently begun learning programming in Excel after coming from a
Matlab background. I find myself constantly running into syntax errors
and other 'Bill Gates effects'. For example I use the macro recorder to
produce the following simple proceedure...

Sub selectrange()
Sheets("Data").Select
Range("A24").Select
Range(Selection, Selection.End(xlDown)).Select
End Sub

That seems grossly inefficient and so I thought the following line
would do the trick...

Sub selectrange()
Sheets("Data").("a24", "a24".End(xlDown)).Select
End Sub

but I get a compile error. Can anyone point out my problem,
understanding that may help me to grasp how VBA likes to talk.

Perhaps members in the list might also like to suggest some favourite
sources of general tips on coming to grips with excel syntax or perhaps
good desk references of the VBA programming language.

I have found the newsgroups and knowledge base give good detail on
specific objects, methods etc... but I have yet to find any good
instructions in the various groups and MVP websites on the basics of
when to use various operators like () , : . = For example, connect
objects with periods or enclose strings with quotes.

Cheers
Nick Flyger