Reputation: 3060
I'm trying to find the right way to insert a cell before the current cell.
I'm looping through a number of cells in a row - when it finds the right value I want it shifted to the right.
I've tried this code: (located post code has a value pointing to the offset relative to the starting active cell)
Dim shiftrng as Range
For ctr = locatedPostCodeIndex To 4
Set shiftrng = Range(cll.Offset(0, locatedPostCodeIndex)).Select
shiftrng.Insert.xlShiftToRight
Next
I get an error: Method range of object _global failed
What is the correct way to insert a cell before a cell?
Upvotes: 1
Views: 178
Reputation:
You do not add .Select
when setting a variable to a range object and you do not require wrapping the cell offset destination in Range(...)
.
Set shiftrng = cll.Offset(0, locatedPostCodeIndex)
Upvotes: 2