Thread: type mismatch
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
vsoler vsoler is offline
external usenet poster
 
Posts: 79
Default type mismatch

I am a beginner in programming VBA

I want to write a function that returns an array where each element is
increased by 1.

However, something is not working. Could you please help me?

Function b(r As Range)
Dim i As Integer, j As Integer
b = r
For i = 1 To UBound(b, 1)
For j = 1 To UBound(b, 2)
b(i, j) = b(i, j) + 1
Next j
Next i
End Function

For example,

............A..........B
1.........1...........2
2.........2...........3
3.........3...........4

In this case, B1:B3 contains the formula =b(A1:a3) entered with
Ctrl-Shift-Enter

Thank you