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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

ChrisUK

Well-known Member
Joined
Sep 3, 2002
Messages
675
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
 

Forum statistics

Threads
1,144,446
Messages
5,724,400
Members
422,550
Latest member
Parvin_B

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
Top