ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Basic Syntax (https://www.excelbanter.com/excel-programming/379906-basic-syntax.html)

Nick_F

Basic Syntax
 
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


Gary Keramidas

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





All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com