jeudi 21 octobre 2021

Check if Named Range is equal to another Named Range

I’m trying to resize a Named Range in Excel if the Named Range “InventoryList” is equal to the Named Range passed into the Sub. I can’t seem to get the correct syntax for this. The "IF" statement is where I'm getting the error. Hopefully someone can help me out.

Thanks in advance.

    Sub Resize_Inventory_Range(InventoryList As Excel.Range)

        Dim xlApp As Excel.Application
        Dim WB As Excel.Workbook
        Dim WS As Excel.Worksheet
        Dim FullInventory As Excel.Range

        xlApp = GetObject(, Constants.ExcelApp)
        WB = xlApp.Workbooks("Product")
        WS = WB.Sheets("Inventory")
        FullInventory = WS.Range("Full_Inventory")

        If InventoryList.Name.Name = "Hardware_Inventory" Then
            FullInventory.Resize(FullInventory.Rows.Count + 1, 4).Name = FullInventory.Name.Name
        End If

    End Sub

Aucun commentaire:

Enregistrer un commentaire