need help on macro/VBA programming selecting a range

  • Thread starter Thread starter Ron Berns
  • Start date Start date
R

Ron Berns

I would like a macro to allow a user to select a cell in column A on Sheet 2.
If the user selects A6 I would like the macro to select the Range (A6:BF6) in Sheet2 and copy that to Sheet1 starting in cell A1.

Thank You in advance.

Ron
 
Sub Copy_to_Sht1()
Range(ActiveCell, Range("BF" & ActiveCell.Row)).Copy _
Destination:=Sheets("Sheet1").Range("A1")
End Sub


Gord Dibben MS Excel MVP
 
Hi,

This might do what you want

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, [A:A])
If Not isect Is Nothing Then
Range(Target, Range("BF" & Target.Row)).Copy Sheet1.[A1]
End If
End Sub

1. To add this code to your file, press Alt+F11,
2. In the VBAProject window, top left side, find your sheet name under your
file name and double click it.
3. Paste in or type the code above.

Whether this macro does what you want depends on what you mean by "starting
in cell A1"
 
Back
Top