1 / 7

Visual Basic for Application (VBA)

Visual Basic for Application (VBA). Basics 2. Write a macro that …. … uses a popup message box to say Hello. ( msgbox ”Hello”) … writes the contents of the active cell in a message box. (you need: msgbox …; activecell.value ) … fills the selection with your name. ( selection.value …)

palila
Download Presentation

Visual Basic for Application (VBA)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic for Application (VBA) Basics 2

  2. Write a macro that … • … uses a popup message box to say Hello. (msgbox ”Hello”) • … writes the contents of the active cell in a message box.(you need: msgbox …; activecell.value) • … fills the selection with your name. (selection.value…) • … fills the selection with the contents of cell A1! (range(”A1”).value)

  3. Write a macro that … • … displays the active workbooks name in a message box. • … puts the workbooks name in the active cell. • … copies contents of the active cell to the one under it. • … displays the active cells value multiplied by 100 in a message box. • … multiplies the active cell by 100 (in place).

  4. Write a macro that … • … multiplies the active cell by the cell on the left, and puts the results into the cell on the right. • Same as above, but this time, display the results in a message box. • … gives a warning in a message box about deleting cell contents, then deletes the contents of the active cell. • … deletes contents from the selection, then changes the background colours to red.

  5. Branching If statementThen True part; Commands if statement is true Else False part; Commands in case statement is false End if If statement1Then True part1; True part1; ElseIfstmnt2 Then True part2; ElseIfstmnt3 Then True part3; Else False part; End if

  6. Exercises for IF conditions • If active cell is empty, change its colour to red. • If the number in the active cell is >10, clear it. • If active cell is < 10, add 1, else clear it. • If active cell is negative, change its colour to red, else make it green.

  7. Exercises for IF conditions • Write a macro that tells us in a message box if the active cell is greater then the one to the right, or not. • Write a macro that tells us in a message box if the active cell is greater than, less than or equal to the one to the right.

More Related