Hi
I am trying to write some data with a VBA function in a worksheet directly below the cell where I added the function.
But unfortunatelly no writing is executed. Do someone see my mistake ?
Thanks
Function test(data As Range)
Dim Output As Range
dataarray = data
x = dataarray(1, 1)
y = dataarray(1, 2)
MsgBox "test: " & "Start"
Row = ActiveCell.Row
col = ActiveCell.Column
MsgBox "test: activ col,row = " & col & "," & Row
MsgBox "test: in sheet " & ActiveSheet.Name
Set Output = ActiveSheet.Range(Cells(col, Row + 1), Cells(col + 1, Row + nd + 1))
Set Output = Selection
Output.Select
Output.Activate
MsgBox "test: output selected"
With ThisWorkbook.ActiveSheet
Range("U5:U5").Value = x + 1
Range(21, 5).Value = x + 2
ActiveSheet.Range(21, 5).Value = x + 3
Set Output.Cells(col + 2, Row + 1).Value = x + 4
Set Output.Cells(col + 2 + 1, Row + 1).Value = y + 4
End With
Application.ScreenUpdating = True
MsgBox "test: data writing ok ??"
End Function
Bookmarks