Search for question
Question

2. Create a VBA array function called ShiftVector(rng.n) with arguments for a range (mg) and in that will

shift the elements of an (m x 1) vector up by n rows. The first n rows of the range rng will "wrap around"

and appear at the bottom of the resulting vector. IMPORTANT: Your array function should be capable

of accommodating strings and data types other than just numbers.

1

2 hi

6789&wN-

3

4 hey

5

8 yo

1-ShiftVector(A1:A9,3)

/output by

END

5

3

9

7

2

import

START

input n

Count rows nr

Ctri-Shift-Enter

Here is a flow chart that you can implement in your ShiftVector function:

-rag

tis(nr-n))

+ b(:) = rng(i+1)

is ar

i-nr-1-1

5

3

OF

3

1234SSTE a

yo

2

2 hi

4 hey

5

6

8 yo

1 hey

#example if

5

9

7

yo

hi

В

7

2

1

6(nr_n+1 →nr)

= [6(79)]

this will become

b(1-ar-n).

=[6(1+6)]

+ 6(1) = (ng(i-nr +n)

"Remember that if you don't have Office 365, you'll need to press Ctrl-Shift-Enter when you enter this

function in Excel!

Fig: 1