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
You can check if the two ranges are the same by comparing their addresses. For example:
MsgBox InventoryList.Address = FullInventory.Address
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras