使用VBA动态调整Listobject表的大小 [英] Resize Listobject Table dynamically with VBA
本文介绍了使用VBA动态调整Listobject表的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过VBA更改对象表的大小,我尝试修改MSDN中有关listobject.resize
方法的代码,但是如果要在每行中加载数据,我想动态地修改.
I want to change the size of the object tables through VBA, I tried modifying the code from MSDN about the listobject.resize
method, but I want to dynamically if a data loaded in each row.
我正在尝试但无济于事的代码:
The code I'm trying but to no avail:
Sub resizedata()
Dim ws As Worksheet
Dim ob As ListObject
Dim Lrow1 As Long
Lrow1 = Sheets("db_goods").Cells(Rows.Count, "E").End(xlUp).Row
Set ws = ActiveWorkbook.Worksheets("db_goods")
Set ob = ws.ListObjects("Table1")
ob.Resize Range("A1" & Lrow1)
End Sub
推荐答案
问题是Range("A1" & Lrow1)
返回范围$A$112
,因为您正在将Range
函数的结果传递给"A1" & "12"
.
The problem is Range("A1" & Lrow1)
returns a Range of $A$112
, because you are passing the Range
function the result of the catenation of "A1" & "12"
.
尝试替换此行:
ob.Resize Range("A1" & Lrow1)
有了这个:
ob.Resize ob.Range.Resize(Lrow1)
这篇关于使用VBA动态调整Listobject表的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文