Thread: Macro Polo
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
steve steve is offline
external usenet poster
 
Posts: 576
Default Macro Polo

Don't downplay the recorder.

Sometimes coding can be tricky, or you just don't remember a bit of code.
The recorder ends up showing the code (plus mundane stuff) and helps you
learn what to do.

When ever I run into a spot the recorder is my first choice before running
to
Google or the MVP's...

--
sb
wrote in message
...
truthfully, i'm not all that interested in using the macro
recorder......not initially anyway. i'm much more
interested in actually learning how to use the code. in
my last job before this one, i learned, from scratch, how
to code ASP pages. it was a great experience learning how
to use vbscript and javascript and html and sql, etc,
etc.....instead of just using something like frontpage or
dreamweaver.

thanks for all of your help, everyone. take care until
next time!

-----Original Message-----

"Bob Phillips" wrote in

message
...
Sub1 revised

Sub Macro1()
Dim iRow As Long
Dim rng As Range
Columns("B:B").Insert Shift:=xlToRight
Range("B1").FormulaR1C1 = "=getlastname(RC[-1])"
With ActiveSheet
iRow = .Range("A" & Rows.Count).End(xlUp).Row
Set rng = .Range("B2:B" & iRow)
rng.FormulaR1C1 = "=getlastname(RC[-1])"
End Sub

--

HTH

Bob Phillips


Perhaps I could just add my 2p-worth as I've been there,

got the T-shirt
etc.

The trouble with the macro recorder is that it's a bit

dumb. You'll find in
your recorded macro code something like:

Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B8")

The macro recorder has filled in B8 (or B98 for all I

know) because that was
the last row of data you had in the spreadsheet at the

time. The macro
recorder has hard-wired in that row number, rather than

what you wanted
which was something that changes as rows are added.

That's what Bob has
given you above.

Incidentally, if you want to stick with your recorded

macro code, what you
want is probably just to change where it says Range

("B1:B8") to:

Range("B1:B" & Range("B1").End(xlDown).Row)

Geoff


.