引用范围对象的范围

我试图find一种方法来引用一个范围从另一个范围,例如,一个范围,持有单元格“A5:A10”,6个单元格在该范围内。 需要的是“B5:B10”旁边的范围。当已经有一个范围对象(在这种情况下为“A5:A10”)时,如何将其引用到下一个范围。

Dim R As Range Dim A As Range Set R = R("A5:A10").Select Set R = 'Code to refer to next column is here 

对不起,这可能是错误的语法开始,它已经有一段时间,因为我在vba编码,这只是为了澄清什么是需要解决这个问题。

尝试这个:

 Sub setRanges() Dim ws As Worksheet Dim rngA As Range Dim rngB As Range 'set the worksheet -- Adjust the worksheet name as required Set ws = ThisWorkbook.Worksheets("Sheet1") 'set the first range to a range in the worksheet Set rngA = ws.Range("A5:A10") ' set the second range to an offest of the first range ' in this case, use an offset of one column, with the same row ' ... remember the offset command takes rows in the first parameter ' ... and the second parameter is for the columns Set rngB = rngA.Offset(0, 1) ' so, zero row offset, ie stay in the same row ' and 1 column offset to get the rngB for one column to the right of rngA rngB.Select ' don't use Select in your code. This is just to demo. End Sub