I am trying to debug this code for quite some time already does anyone know what is the problem in it?
Code:
Sub Find_Field_List()
Dim Last_Field As Integer
Dim Field_List() As Variant
Last_Field = Summary_File.Sheets("Settings").Cells(1, 1).End(xlDown).Row
Field_List() = Summary_File.Sheets("Settings").Range(Cells(2, 1), Cells(Last_Field, 1))
End Sub
Error(highlights line starting with Field_List()):
RunTime Error 1004
Application-Defined or Object-Defined Error
Immediate Window:
?Summary_file.Sheets(2).Name
Settings
Split MBSA.xlsm
?Range(Cells(2,1),Cells(5,1)).Count
4
?Last_Field
5
?Summary_File.Sheets(2).Range(Cells(1,1))
Fields
Summary_File.Sheets("Settings")before each call toCells. If you just putCells, Excel interprets that as cells in the active sheet, even if it's in the arguments to aRangefunction that's correctly-scoped.Field_List=Summary_File.Sheets("Settings").Range(Cells(2, 1), Cells(Last_Field, 1)).Value. See the answer that I posted. You may have to refresh the page.End(xlDown).RowYou may end up selecting the entire column! If you want to select only till the last row then you may want to see THIS