Im trying to create a function in VBA that copies data from one sheet to another based on the input to the function. However, I'm having great difficulty in using the arguments to the function in the actual function itself.
Below is my code: as you can see, the range I want is hardcoded in for now, and this works! But I cannot get it to accept the range I pass as an argument to the function. What am I doing wrong?
data should be in place of range(F35:F65) and target should be in place of range(C6)
Function Copytranspose(data As Range, target As Range)
Worksheets("Data").Activate
ActiveSheet.Range("F35:F65").Copy
Worksheets("Totalizers").Activate
ActiveSheet.Range("C6").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Function
Sub tempo()
Call Copytranspose(Range("F35:F65"), Range("C6"))
End Sub
target.resize(data.rows.count,data.columns.count).value=data.value
– Nathan_Sav