Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I tried recording a macro that inserts a row above the selected cell and then
puts the word count in the cell above the selected cell. I want it to happen
to whichever cell I select but when I run it, it always goes back and does it
to the cell that I originally recorded it on. Im sure it is just something I
am doing, but could some one help out???

CHris
 
I got this when I recorded a macro:


Christopher said:
I tried recording a macro that inserts a row above the selected cell and then
puts the word count in the cell above the selected cell. I want it to happen
to whichever cell I select but when I run it, it always goes back and does it
to the cell that I originally recorded it on. Im sure it is just something I
am doing, but could some one help out???

CHris
 
I got this when I recorded a macro:

Option Explicit
Sub Macro1()
Rows("12:12").Select
Selection.Insert Shift:=xlDown
Range("A12").Select
ActiveCell.FormulaR1C1 = "Count"
End Sub

I could generalize it to this:

Option Explicit
Sub Macro1A()
Dim myCell As Range
Set myCell = ActiveCell

With myCell
.EntireRow.Insert
.Offset(-1, 0).Value = "Count"
End With
End Sub
 
Sub ThisMacro()
With Selection
.EntireRow.Insert
.Cells(0, 1).Value = "Count"
End With
End Sub

Hope it helps.
 

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

Back
Top