in the following sub - that simply copies one named range to another on a different sheet - has always worked. now apparently something changed and it throws an unspecified runtime error
Sub prime_current_sim_input()
With Range("varianten_in")
.Value2 = Range("sim_direktinput_vals").Value2
End With
End Sub
In Contrast, the following works fine
Sub prime_current_sim_input()
Sheets("SIM").Select
Range("$B$3:$GN$3").Select
Selection.Copy
Sheets("Varianten").Select
Range("H3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
i'm at a complete loss as to what might cause this? ive already checked:
- the first method has worked on my machine before and still works on others
- All other subs, that work in a similar fashion on other named ranges also throw the same error
- I have previous versions of the same file that work just fine
- windows 10, excel 2016.
- the named range dimensions/addresses haven't changed and are correct, they correspond.
- all involved named ranges are defined on workbook level
Another Example of not working code, same error
Public Function Save_variant_inputs(offset As Integer) As Boolean
' copy row to primer range "varianten_in"
With ThisWorkbook.Worksheets("Varianten").Range("varianten_in")
.offset(offset).Value2 = .Value2
End With
Save_variant_inputs = True
End Function
Here is a view of the involved ranges: i dont see why this wouldnt work, can it be something with permission, sheet protection (is off on both)
overwatch screenshot of involved ranges
The error occurs in all lines of type
Range("a").Value2 = Range("b").Value2
it makes no difference how the subs and functions are called (both from vba directly and via a button yields the same result)
since this code broke without me touching it i suspect the cause is located somewhere else, not related to the code itself. it has worked before
i have added the sub to another workbook and there, it works fine.