Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Sebastion Anderson   on Oct 17 In MS Office Category.

  
Question Answered By: Joseph Evans   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.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

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


Tagged: