Experimenting in the Immediate Window

If you want to experiment with code, you can use the VBE's Immediate window. Use View O Immediate Window, press Ctrl+G, or click the Immediate Window button on the Debug toolbar to make the Immediate window visible. You can tile the Excel window and the VBE window so you can type commands into the Immediate window and see the effects in the Excel window, as shown in Figure 1-20.

■3' e

Heine

¿J ■ fteesrtisMHsm - Miwasett E«rel Insert Page Lay cut Formulas Data Review View t?evelc|aèr

® - - •*

! BZ

-

f* Sales

É

i

A

B

C D E

F

a

H

1 J

*

H

o '*

i

Sales

Sales

3

J

a

s

7

3

9

10

|

11

1

™ ! !■

P.tarty Í3 .

.11

s ¡n Hi.

m ¿i

H € - A

Vjew insert Format Debug Run j - • MJ J ^

Tools Add Ins Window Help

% jr $

" ¿i

■, i. -

= f^ -= Ü. (

Project - VBAProject Xj mm fc

Sj Sheets (Sheet3 ® ThisWorkhook M Q Modules

Properties- Sheet* 5heet3 Worksheet Alphabetic Categorized | (Name}

DispiayPageBreaks

DisplayRightToLeft

EnableAutoFilter

EnableCalculation

EnableFormatCondition!

EnableQutiining

Immediate

*J

A

Range ("Bî,r) .Select ActiveCell .Value=T,5ale3T' 2Rar>ge ("B^""} .Value Sales

Range ( "B2 ,r) .Copy De3cmationï=Range (" J2")

lEnablePivotTable

»

«1 I

When a command is typed in and Enter is pressed, the command is immediately executed. To execute the same command again, click anywhere in the line with the command and press Enter again.

Here, the Value property of the ActiveCell object has been assigned the text "Sales". If you want to display a value, you precede the code with a question mark, which is a shortcut for Print:

?Range("B2").Value

This code has printed Sales on the next line of the Immediate window. The last command has copied the value in B2 to J2.

0 0

Post a comment