how do i...

jsw6

New Member
Joined
Sep 7, 2002
Messages
3
create a macro using this code, i'm a rookie.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("Sheet2").Range("A1") = ActiveCell.Row
End Sub

also, how would i adjust the above code to take three specific cells within the active row in sheet1 and put them into three separate cells in sheet2?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try this code:

For Each c In Range("A4,C4,F4")
Worksheets("sheet2").Range(c.Address) = c.Value
Next

It assumes you want the cells copied from the same columns to the same columns, ie missing out unselected columns

You can change the range in the first line to have as many cells as you like or use a different format if all the cells are together (A1:A10)

HTH
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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