使用 Excel 范围内的变量 [英] Using variables in Excel range

查看:78
本文介绍了使用 Excel 范围内的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用变量来查找范围,然后使用这些变量来激活选择.

I am looking to use variables to find a range as well as then use those to activate a selection.

这是我的代码:

Dim first As Integer
Dim Last As Integer

first = (ActiveCell.Row + 1)
Selection.End(xlDown).Select
Last = (ActiveCell.Row - 1)
Range(("J" & first) : ("J" & last)).Select

但是,我在 Excel VBA 2010 中遇到了语法错误.

However, I am getting a syntax error on this in Excel VBA 2010.

任何建议.

谢谢,

推荐答案

Range 语法是 Range("A1:B2") 因此您需要将代码修改为:

The Range syntax is Range("A1:B2") so you will need to modify your code to:

Dim first As Integer
Dim Last As Integer

first = (ActiveCell.Row + 1)
Selection.End(xlDown).Select
Last = (ActiveCell.Row - 1)
Range("J" & first & ":" & "J" & Last).Select

这篇关于使用 Excel 范围内的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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