[英](Excel VBA) How to insert multi columns and cell.value for those columns into excel sheet before found cell?
[英]Excel VBA insert cell before current cell
我正在嘗試找到在當前單元格之前插入單元格的正確方法。
我在一行中遍歷多個單元格-當它找到正確的值時,我希望它向右移動。
我嘗試了以下代碼:(定位的郵政編碼具有指向相對於起始活動單元格的偏移量的值)
Dim shiftrng as Range
For ctr = locatedPostCodeIndex To 4
Set shiftrng = Range(cll.Offset(0, locatedPostCodeIndex)).Select
shiftrng.Insert.xlShiftToRight
Next
我收到一個錯誤: Method range of object _global failed
在單元格之前插入單元格的正確方法是什么?
在將變量設置為范圍對象時,無需添加.Select
,並且不需要將單元格偏移量目標包裝在Range(...)
。
Set shiftrng = cll.Offset(0, locatedPostCodeIndex)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.