I am trying to run a code that was run by someone else and I am getting a runtime error. In the last two lines
Sub calculateCompositions()
Set prodProfilesSheet = Workbooks("Production Profiles (revised).xlsb").Sheets("Ref Compr - Wells")
Set fluidCompSheet = Workbooks("Production Profiles (revised).xlsb").Sheets("Well Base Compositions")
Set flashCalcSheet = Workbooks("Production Profiles (revised).xlsb").Sheets("Well Base Compositions")
total_columns = prodProfilesSheet.Range("C1").CurrentRegion.Columns.Count
c = ActiveCell.CurrentRegion.Column
numberOfRowsInRegion = ActiveCell.CurrentRegion.Rows.Count
numberOfheaderRows = 6
numberOfDataRows = numberOfRowsInRegion
firstDataRow = ActiveCell.Row
Do While c < total_columns
fluidCompSheet.Range("L2").Value = current_well_name
compositionName = fluidCompSheet.Range("O1").Value
fluidCompSheet.Range("O3:O32").Copy
flashCalcSheet.Range("I8").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
If current_well_name = "Existing wells" Then
Exit Do
For r = firstDataRow To firstDataRow + numberOfDataRows
prodProfilesSheet.Cells(r - 5, c).Activate
Application.Goto Reference:=Active, Scroll:=True
'...
end sub
If I don't activate the file and put the cells inside the application Goto like this:
Application.Goto Reference:=prodProfilesSheet.Cells(r - 5, c), Scroll:=True
The code runs but does not do what it supposed to (which is copy the data from the main file to a secondary one, run the calculate composition sub and paste the resulting data back to the main file) . Since, I did not write the code, I am not really sure what is happening in those two lines.
Any ideas on how to get out of it?
Thanks