I am getting error while swapping with two sheets. I open one sheet and paste some data in this,after that I call a function which opens another sheet.but when I again paste data in the first sheet it throws error.
For y = 1 To size
Set src = Workbooks.Open("C:Template\Mapping.xlsx")
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("B" & rowCntr).Value = "abc"
newValue= getNewValue()
rowCntr=rowCntr+1
Next
public Function getNewValue()
Dim newV=123
Set src = Workbooks.Open("C:Template\Mapping - Development v1.0.xlsx")
getNewValue=newV
End Function
For the first time it works properly but after calling the function getNewValue()
it throws error "Subscript out of range" at Worksheets("Sheet1").Range("B" & rowCntr).Value = "abc" line.
Please help.
Dim newV=123
is invalid. You cannot initialize variables in VBA. - Paul Ogilvie