View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Billy Liddel Billy Liddel is offline
external usenet poster
 
Posts: 527
Default EXCEL macro that will vary when copied

Michael

The following will do what you want

Sub t()
Dim r As Long
r = ActiveCell.Row
Cells(r, 1) = 1
Cells(r, 2).Select
End Sub

Copy this into a VB module (ALt + F11) select Insert, Module and paste the
macro into the module.

Press Ctrl + Q to return to the sheet.

I would not use a macro button to execute the macro unless you have Freezed
the panes. Instead assign a shortcut key. While in Excel choose Tools, Macros
(Alt + F8), click once on the macro to select it if necessary and click the
Options Button.

Assign the Letter Q, it does not seem to be used for anything and click ok.
Press Ctrl + Q to run the code.

Peter

"Michael52" wrote:

I want a "macro button" that acts on one row to be able to be copied in many
other rows(1200), without having to write a new macro for each row. (to
Copy-Paste it and have it act the same as an EXCEL formula, changing the
relative addresses automatically).
In paricular, all the button does is take the cursor "Home" in the same row
(leftmost column), insert the digit "1" in that cell and move one column to
the right.
Any ideas? (I don't speak "Basic"....)