View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Selecting The Last Row

Yes, I am saying that. But ... although it may work, it is more error prone
as it is more difficult IMO to know where you are, rather than using an
index within a loop. Also, it is much harder to amend later, for similar
reasons.

As to a book, depends upon where your current skill level is, but I would
suggest you go down to your local bookstore at look at John Walkenbach's VBA
for Dummies, see if you think it will help.

--
HTH

Bob Phillips

"Minitman" wrote in message
...
Hey Bob,

So what you are saying is, Select will work but not efficiently. I am
still fairly new at programming and am always looking for the most
efficient way to write the code. Can you recommend any GOOD books or
classes on the subject?

I finally got this to work from the UserForm paste down, but that does
not answer the problem of all the entry that is already there. That
is where the CF worked well. Oh well, I guess a few hours of manually
fixing the old formats one time is better then taking a few days to do
it automatically. <G

There is still a LOT of data to be entered.

Thanks for the assistance, it really helped.

-Minitman


On Thu, 21 Jul 2005 09:50:00 +0100, "Bob Phillips"
wrote:

What I mean is that selecting is inefficient and also difficult to read

as
you try to follow code.

Take this example

Range("A1").Select
Do
If Activecell.Value 17 Then
Activecell.Offset(0,10).Value = "Valid"
End If
Activecell.Offset(1,0).Select
Loop Until Activecell.value = ""

All that selecting is keeping the system very busiy, adjusting its

pointers,
re-displaying the activecell, etc.

This can be written as

For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row
If Cells(i,"A").Value 17
Then Cells(i,11).Value = "Valid"
End If
Next i

No selecting, more efficient, easier to raed (IMO).

Of coures this is a simple example, it gets more relevant in big, complex
code.