0

When I run this I get a run time error (13) telling me after setting (what I think is a) range in those workbooks that it is, in fact, is not a range. I think there's a problem in my nomenclature, but can you guys help me out? Thanks

Option Explicit
Dim OGBook As Workbook
Dim NAVBook As Workbook
Sub NAVCheck()

Dim NetAmountColumn As Range
Dim TargetRange As Range
Dim SingleCell As Range
Dim CodeColumn As Range

Set NAVBook = FindWorkbook(sWithNameLike:="This_function_isnt_the_problem")
Set OGBook = Workbooks("some_file.xlsm")
Set NetAmountColumn = Workbooks(OGBook).Range("i2", Range("i1").End(xlDown))
Set TargetRange = Workbooks(OGBook).Range("o2", Range("o1").End(xlDown)).Offset(0, 1)
Set CodeColumn = Workbooks(NAVBook).Range("c2", Range("c1").End(xlDown))


If NAVBook Is Nothing Then
    MsgBox ("NAV Workbook doesn't seem to be open. Please open current NAV workbook and run the program again.")
    
Else
    
    [Something I haven't written yet]
 
End If


End Sub

Sorry for the sloppy indentation.

  • A `Workbook` does not have a `Range` property, btw. – BigBen Oct 18 '22 at 17:32
  • `Set NetAmountColumn = OGBook.Worksheets("Yourworksheetnamehere").Range(...)` – BigBen Oct 18 '22 at 17:32
  • Also see [this](https://stackoverflow.com/questions/8047943/excel-vba-getting-range-from-an-inactive-sheet) for how to reference a range on an inactive sheet properly. – BigBen Oct 18 '22 at 17:36

0 Answers0