Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

standard pattern of syntax

  Asked By: Sebastion    Date: Oct 17    Category: MS Office    Views: 664
  

I'm a new person studying VB and Excel. I have some questions. Are
there anybody please help me?

I would like to know " the standard pattern of the syntax used in
vbeditor in Excel"

I'm confusing because I see a lot of patterns used in example of model I
studied.
Ex:
ThisWorkbook.Worksheets(1).UsedRange.Rows.Count
ActiveWorkbook.Worksheets.Add
UpperFileName = UCase(ActiveWorkbook.Name)
Worksheets(iSheet).Activate

There are different patterns. I don't know how to start studying.
Thank you in advance for your help.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Joseph Evans     Answered On: Oct 17

Generally the syntax  is to apply a method to an object. This is expressed by
stating the object, then a period (full stop) then the method.

Also assignments can be made by using the equals sign (=).

Your examples are constructed as follows

ThisWorkbook.Worksheets(1).UsedRange.Rows.Count

This is not a complete line of code as cont is a property not a method. It
gives a number equal to the number of rows  in the used range of the first
worksheet in the workbook it is running in.

ActiveWorkbook.Worksheets.Add

This adds a worksheet to the worksheets  in the active workbook (the workbook
which has the focus at the time)

UpperFileName = UCase(ActiveWorkbook.Name)

The finds the name of the active workbook, converts it to upper case, and
assigns it to the variable UppperFileName

Worksheets(iSheet).Activate

This Activates (moves the focus to) a worksheet called by the content of the
variable iSheet.

The best way to learn VBA is to start  by recording macros for actions you
carry out, then look at those macros and try to understand what they are
doing.

Then try altering the macros a bit to make them do something different. Run
them and see if they do what you expected.

Then you can try writing lines of code yourself and again try them out.

The intellisense in the VBA editor helps a lot. When you put in a period
after an object it will (usually) list the properties and methods available.

If you type a property or method in the editor and then click F1 it will bring
up a help  file that tells you the syntax and working of that item.

You are starting on an exiting path even though it will be frustrating at
times. Enjoy it. If you have any specific questions  post them here and we
will try to help.

 
Answer #2    Answered By: Janis Hart     Answered On: Oct 17

Can anybody tell me how do I synchronize the scroll bars in different list
boxes? I mean, I want to move
the second scroll bar simultaneously while moving the first scroll bar. Any
help would be greatly appreciated.

 
Answer #3    Answered By: Shiv Patel     Answered On: Oct 17

I think this is possible but I do not know how, and don't have the time at the
moment to find out. Sorry.

But I wonder if you could achieve what you want by having one list box with
two columns.

 
Answer #4    Answered By: Marnia Mian     Answered On: Oct 17

If you're new to Excel VBA, I'd strongly suggest you check out this terrific
newbie series of article in TechTrax...

<url start>
pubs.logicalexpressions.com/.../LPMFrame.asp
TH=33
<url end>

 
Didn't find what you were looking for? Find more on standard pattern of syntax Or get search suggestion and latest updates.




Tagged: