简体   繁体   English

Sheet.Range(Sheet,Cells(x,y), Sheet.Cells(x2,y2)) 语法

[英]Sheet.Range(Sheet,Cells(x,y), Sheet.Cells(x2,y2)) Syntax

I would like to add multiple Cells through the.Cells(x,y) Syntax to a Range named "ValueRange" like so:我想通过 .Cells(x,y) 语法将多个单元格添加到名为“ValueRange”的范围中,如下所示:

Dim ws As Worksheet
Dim j As long
Dim Valuerange As Range

j = 6 'rowNumber 6
Set ws = ThisWorkbook.Worksheets("My Worksheet1")
Set Valuerange = ws.Range(ws.Cells(j, 3), ws.Cells(j, 5), ws.Cells(j, 7), ws.Cells(j, 9))

and I would like to Select this range through the same format later after changing j (rowNumber)并且我想在更改 j (rowNumber) 之后通过相同的格式来 Select 这个范围

ws.Range(ws.Cells(j, 3), ws.Cells(j, 5), ws.Cells(j, 7), ws.Cells(j, 9)).Select

But I always get errors with this Syntax "Wrong Number of Arguments or invalid property assignment"但我总是收到此语法“错误编号 Arguments 或无效属性分配”的错误

Can anyone help?任何人都可以帮忙吗? Cheers干杯

See comments of question for easy answer through using a Union-Statement instead of Range-Object通过使用 Union-Statement 而不是 Range-Object,请参阅问题评论以便轻松回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 计算另一个包含 Y 的工作表中的最后 X 个单元格,以百分比表示 - Count last X cells from another sheet containing Y, as percentage 仅当单元格 1 包含“x”且单元格 2 包含“y”时才将行复制到另一个工作表中 - Copy rows into another sheet only if the cells1 contains "x" and cell2 contains "y" Google工作表如果工作表1中的X =工作表2中的Y,则在工作表1中显示工作表2中的Z - Google Sheets If X in Sheet 1 = Y in sheet 2, display Z from sheet 2 on sheet 1 如果工作表“ X”中的单元格包含工作表“ y”的名称,请删除行工作表“ x” - Delete row sheet 'x' if cell in sheet 'X' contains name of sheet 'y' 在sheet(x)列(x)中查找值,如果它们与粘贴行匹配,则与sheet(y)列(y)中的值匹配 - Look up values in sheet(x) column(x), match to values in sheet(y) column(y), if they match paste row 将单元格范围复制到另一张纸上 - Copying range of cells to another sheet 引用单元格以指定图纸范围 - Referencing cells to specify sheet range 复制一系列单元格而不是整个工作表 - Copy a range of cells and not the whole sheet 将单元格范围插入另一张工作表 - Insert range of cells to another sheet 如果某个范围中的单元格的值为“ x”,则将某个范围的单元格复制并粘贴到另一张工作表中 - If cell in a range has value “x” copy and paste a range of cells into a different sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM