View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Help with shortening/cleaning some code please

Range([C2], [L65536].End(xlUp)).Select

Don't use notation like the above. It incurs tremendous overhead.

Range(Range("C2"),Range("L65536").End(xlup)).Selec t

would be much faster although you also need to learn how to program without
using select except where it is absolutely required.

--
Regards,
Tom Ogilvy

"Martin" wrote in message
...
Roy,

I am no expert. I have been playing with Excel/VBA for some years now and

my
limited knowledge has come from searching the newsgroups for similar
scenarios.

If YOU simplify your code, you stand a better chance of understanding it
should you need to amend it in the future.

Three points:

1. Read http://www.cpearson.com/excel/newposte.htm

2. Look at the code yourself...when recording this procedure, you have

made
some errors and then rectified them, e.g.,

Selection.NumberFormat = "0.0"
Selection.NumberFormat = "0.00"
and
Selection.Font.Bold = True
Selection.Font.Bold = False

It's unlikely that both lines are required. Start with those.
Look for others.

3. "the row quantities in the "real" file that this
macro has been created for are going to be varying
onevery new incstance of the file...."

Where you have

"Range("C2:L340").Select"

assuming you have no blank cells in Column L,

Range([C2], [L2].End(xlDown)).Select

will work for the last cell down from L2, but
if cells may be blank then you would probably be better
using

Range([C2], [L65536].End(xlUp)).Select

because this goes from L65536 upwards.

Try it. Post back with specific problems and these can be
answered by someone significantly better than me
(and there are lots of those!).

Martin


roy wrote in message
om...
Hi

<snip
CODE ENDS HE::::::::::::::::::::::