PDA

View Full Version : Solved: offset property



austenr
11-10-2005, 09:46 AM
trying to use offset in the code below to cut the range value and paste it up 2 cells. Also, can I incorporate if cells = anything alpha clear contents. Thanks

Sub moveSocial()
Dim myrange As Variant

For Each myrange In Range("A3:A29277")
If IsNumeric(myrange) Then
Cells.myrange.Copy Destination:=Cells(myrange).Offset(0, -2)
End If
Next myrange
End Sub

mvidas
11-10-2005, 09:52 AM
Sure thing, give this a try:Sub moveSocial()
Dim myrange As Range

' For Each myrange In Range("A3", Range("A65536").End(xlUp)) 'used cells in A
For Each myrange In Range("A3:A29277")
If IsNumeric(myrange) Then
myrange.Copy Destination:=myrange.Offset(-2, 0)
Else
myrange.ClearContents
End If
Next myrange
End SubMatt

mvidas
11-10-2005, 09:53 AM
Also, if you only want the value copied (and not a formula, if there is one), then make the following change:' myrange.Copy Destination:=myrange.Offset(-2, 0)
myrange.Offset(-2, 0).Value = myrange.ValueMatt

austenr
11-10-2005, 10:39 AM
Thanks Matt.. Solved :cloud9: