How to select multi offset range?

alee001

Board Regular
Joined
Sep 9, 2014
Messages
154
Office Version
  1. 2010
Platform
  1. Windows
How to select multi offset cells in range?Anyone advice me...Thanks.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

With Range("combin_oth")
    If Target = .value Then
         Target.Copy: Range(".Offset(-8, 37).value, .Offset(-4, 37).value, .Offset(1, 37).value").PasteSpecial xlPasteFormulas 'error select range??
        Application.CutCopyMode = False
    End If
End With

End Sub
 
Try using union:

Code:
Sub a1084949a()
With Range("A1")
Range("A2").Copy: Union(.Offset(0, 1), .Offset(0, 4), .Offset(0, 6)).PasteSpecial xlPasteFormulas
End With
End Sub

The code only select B1, E1 and G1 but nothing paste formula from A1?
 
Last edited:
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
The code only select B1, E1 and G1 but nothing paste formula from A1?

It offset from A1 but the formula is in A2, if you want to copy formula from A1 then just change
Range("A2") to Range("A1")
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

With Range("combin_oth")
    If Target = .value Then
         Target.Copy: Range(.Offset(-8, 37).Address(0, 0) & "," & .Offset(-4, 37).Address(0, 0)  & "," & .Offset(1, 37).Address(0, 0)).PasteSpecial xlPasteFormulas
        Application.CutCopyMode = False
    End If
End With

End Sub
Or
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

With Range("combin_oth")
    If Target = .value Then
         Target.Copy: Union(.Offset(-8, 37), .Offset(-4, 37), .Offset(1, 37)).PasteSpecial xlPasteFormulas 'as written by Akuini
        Application.CutCopyMode = False
    End If
End With

End Sub
 
Last edited:
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top