VBA Excel中获取图片的底行 [英] vba excel get picture's bottom row

查看:53
本文介绍了VBA Excel中获取图片的底行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有图片的电子表格.我不知道图片的大小(可能会有所不同).我想在变量中获取图片的最后一行(我想在图片底部保留空白行,并开始在下一行中填充数据).您能帮我弄清楚语法吗?

I have a spreadsheet with a picture. I don't know the size of the picture (it may vary). I want to to get the last row of the picture in a variable (I want to leave a blank row to the bottom of the picture and start filling data in the next row). Could you help me figure out the syntax?

我什至不知道如何将图片变成变量.

I can't even figure out how to get the picture into a variable..

我能够使用以下代码执行此操作:

I was able to do this with the following code:

 Dim testPic As Object
 For Each testPic In ActiveSheet.Pictures
    h = testPic.Height
    cellHeight = Cells(ImageTopRow, ImageLeftCol).Height
    nRows = h/cellHeight
 Next

但是:一种.我不需要foreach,收藏中只有一张照片,我只是想不出如何获得第一张照片.b.应该有一种更简单的方法,对吧?

But: a. I don't need a foreach, there's only one picture in the collection, I just can't figure out how to get the first one. b. There should be an easier way, right?

谢谢,李

推荐答案

Dim pic As Shape
Set pic = ActiveSheet.Shapes(1)

MsgBox pic.BottomRightCell.Row

将显示右下角的单元格位置,即

will show you the cell's location of the right bottom corner, ie

这篇关于VBA Excel中获取图片的底行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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