need help on macro/VBA programming selecting a range

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
 
G

Gord Dibben

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


Gord Dibben MS Excel MVP
 
S

Shane Devenshire

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top