如何确定一行中使用的列数 [英] how to determine the number of used columns in a row

查看:30
本文介绍了如何确定一行中使用的列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定垂直行中已用列的数量,并将其向右移动.到目前为止,这是我所拥有的,但这似乎行不通.请帮忙.

I am trying to determine the number the used columns in a perticular row and shift them right. This is what I have so far but this does not seem to work. Please help.

Dim LastCol As Integer
LastCol = DataSheet.Cells(arr(z)(1), DataSheet.Cells(arr(z)(1).Columns.Count))
'arr(z)(1) is an integer extracted from a 2 multidimensional array           
Dim rng As Range

Set rng = Range(DataSheet.Cells(arr(z)(1), 2), DataSheet.Cells(arr(z)(1),LastCol))   
rng.Insert Shift:=xlRight

推荐答案

Dim LastCell as Range   
With DataSheet
    Set lastCell = .Cells(arr(Z)(1), Columns.Count).End(xlToLeft)
    .Range(.Cells(arr(Z)(1), 2), lastCell).Insert Shift:=xlShiftToRight
End With

这篇关于如何确定一行中使用的列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆