i am new here and try to learn VBA Excel but it doesn't work.
I want a function with one paramter to insert by each cell an increased value.
Option Explicit
Function DefineAI(rngToSet As Range) As String
Dim intCounter As Integer
Dim cell As Range
On Error GoTo Fehler
Let intCounter = 1
For Each cell In rngToSet.Cel
'cell.Value = intCounter 'Test 1: It crashes with no error
Range(cell).Value = intCounter 'Test 2: It crashes with no error
intCounter = intCounter + 1 'intCounter++ ?? not important yet
Next
DefineAI = "test"
Exit Function
Fehler:
Debug.Print Err.Description
End Function
It crashes on two different Computers with no Error! Actually it doesn't crash, but just stop.
I have also try with a sub, but the same result.
for each cell in rngtoset2.cell.value=intcounter3. omit thelet