So sorry if this is really obvious, but I'm having some trouble connecting two pieces of information.
I have a one-cell range (for example, like A1) and a second, larger range (such as A1:C223). I want to be able to write some code that will make a new range using the column of the one-cell, and the number of rows of the larger range (so in this example, it would end up being A1:A223).
I want to use this specifically to create a loop later, but I'm having trouble creating this range first. Any help would be appreciated.
I think I understand what you want. See if this works:
Sub test()
Dim rangeA As Range, rangeB As Range, combRange As Range
Set rangeA = Range("A1")
Set rangeB = Range("A1:C223")
Set combRange = Range(Cells(rangeB.Rows(1).Row, rangeA.Column), _
Cells(rangeB(rangeB.Rows.Count, 1)(1).Row, rangeA.Column))
Debug.Print combRange.address
End Sub
Edit: This is a little too much perhaps, it looks like @SiddharthRout has a great solution too in the comments :D
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments