CHE110-L08 - declared using the Dim or Public keywords. Dim...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CHE110 Introduction to Programming & Problem Solving
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Local Variables Range(". ..").Value Dim x As Double, y As Double x = Range("C2").Value y = 2 * x Range("C3").Value = y Dim x As Double, y As Double x = Range("C2").Value y = 2 * x Range("C3").Value = y Worksheet VBA Worksheet VBA Task: Read in value contained in a cell, output 2X value to another cell.
Background image of page 2
Range Object Variables Dim x As Range, y As Range Set x = Range("C2") Set y = Range("C3") y.Value = 2 * x.Value OR y = 2 * x Dim x As Range, y As Range Set x = Range("C2") Set y = Range("C3") y.Value = 2 * x.Value OR y = 2 * x x and y are now cells C2 and C3 new value for y automatically reflected in cell C3 Range object variables Task: Read in value contained in a cell, output 2X value to another cell.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Declaring & Assigning Object Variables • Object variables are
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: declared using the Dim or Public keywords. Dim x As Range Creates variable x of type Range Public sheet As WorkSheet Creates variable sheet of type WorkSheet Objects are assigned to object variables using the Set keyword. Set x = Worksheets(1).Range(A1:C10) Set sheet = Worksheets(Data) Range Object Variables Representing Multiple Cells Dim x As Range, y As Range Set x = Range("B4:B6") Set y = Range("C4:C6") y(1) = 2 * x(1) y(2) = 2 * x(2) y(3) = 2 * x(3) Dim x As Range, y As Range Set x = Range("B4:B6") Set y = Range("C4:C6") y(1) = 2 * x(1) y(2) = 2 * x(2) y(3) = 2 * x(3) Use indices to refer to individual cells Task: Read in values contained in column of cells, output 2X value to adjacent column of cells....
View Full Document

Page1 / 5

CHE110-L08 - declared using the Dim or Public keywords. Dim...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online