VBA Select range with two variables

南笙酒味 提交于 2019-12-13 02:57:36

问题


I am trying to select range. I have no problem selecting it with variable, lets say x and y are variables. I have no problem writing code to select range from e.g. A1:By. But How do I select a range from Ax:By ? Is there simple one line solution to this?

Thanks in advance for help

My code for A1:By which works

Sheets("Sim").Range("A1:B" & y).Select

My made code from Ax:By which does not work

Sheets("Sim").Range("A" & x ":B" & y).Select

回答1:


You left out an ampersand....

Sheets("Sim").Range("A" & x & ":B" & y).Select


来源:https://stackoverflow.com/questions/46449578/vba-select-range-with-two-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!