Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default making code more efficient

After getting a procedure to large error I have finally got around to
reducing my code instead of just having what works.

I have 5 text boxes in a form and at the moment I evaluate each box exactly
the same way but I have sections of code for each box when I could just have
a loop stepping by one.

The boxes are called rider1 through to rider 5. I am having trouble with
this code at the moment

If Rider5.Value < 100 Or IsNumeric(Rider5) = False Then

I have now got

For Box = 5 to 1 step -1

If "Rider" & box.Value < 100 Or IsNumeric("Rider" & box) = False Then

This does not work.

I have also posted this at the bottom of my procedure to large post but
thought more people might see it here.

Any ideas.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default making code more efficient

In what module is the code posted? Module1, UserForm, Sheet?


"NDBC" wrote in message
...
After getting a procedure to large error I have finally got around to
reducing my code instead of just having what works.

I have 5 text boxes in a form and at the moment I evaluate each box
exactly
the same way but I have sections of code for each box when I could just
have
a loop stepping by one.

The boxes are called rider1 through to rider 5. I am having trouble with
this code at the moment

If Rider5.Value < 100 Or IsNumeric(Rider5) = False Then

I have now got

For Box = 5 to 1 step -1

If "Rider" & box.Value < 100 Or IsNumeric("Rider" & box) = False Then

This does not work.

I have also posted this at the bottom of my procedure to large post but
thought more people might see it here.

Any ideas.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default making code more efficient

Hasn't this already been posted and answered?

"NDBC" wrote:

After getting a procedure to large error I have finally got around to
reducing my code instead of just having what works.

I have 5 text boxes in a form and at the moment I evaluate each box exactly
the same way but I have sections of code for each box when I could just have
a loop stepping by one.

The boxes are called rider1 through to rider 5. I am having trouble with
this code at the moment

If Rider5.Value < 100 Or IsNumeric(Rider5) = False Then

I have now got

For Box = 5 to 1 step -1

If "Rider" & box.Value < 100 Or IsNumeric("Rider" & box) = False Then

This does not work.

I have also posted this at the bottom of my procedure to large post but
thought more people might see it here.

Any ideas.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default making code more efficient

The OP said he couldn't get it to work. I am wondering where he has the
code.

If it is behind the user form then:

For box = 1 To 2
MsgBox Me.Controls("rider" & box).Text
Next

If he is trying it from the project module then he will need to make the
form modeless.


"Barb Reinhardt" wrote in message
...
Hasn't this already been posted and answered?

"NDBC" wrote:

After getting a procedure to large error I have finally got around to
reducing my code instead of just having what works.

I have 5 text boxes in a form and at the moment I evaluate each box
exactly
the same way but I have sections of code for each box when I could just
have
a loop stepping by one.

The boxes are called rider1 through to rider 5. I am having trouble with
this code at the moment

If Rider5.Value < 100 Or IsNumeric(Rider5) = False Then

I have now got

For Box = 5 to 1 step -1

If "Rider" & box.Value < 100 Or IsNumeric("Rider" & box) = False Then

This does not work.

I have also posted this at the bottom of my procedure to large post but
thought more people might see it here.

Any ideas.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default making code more efficient

Check your other post.

NDBC wrote:

After getting a procedure to large error I have finally got around to
reducing my code instead of just having what works.

I have 5 text boxes in a form and at the moment I evaluate each box exactly
the same way but I have sections of code for each box when I could just have
a loop stepping by one.

The boxes are called rider1 through to rider 5. I am having trouble with
this code at the moment

If Rider5.Value < 100 Or IsNumeric(Rider5) = False Then

I have now got

For Box = 5 to 1 step -1

If "Rider" & box.Value < 100 Or IsNumeric("Rider" & box) = False Then

This does not work.

I have also posted this at the bottom of my procedure to large post but
thought more people might see it here.

Any ideas.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
making code more efficient timmulla Excel Discussion (Misc queries) 3 January 23rd 07 02:16 PM
Efficient Code GregR Excel Programming 7 June 27th 05 04:09 PM
More Efficient code than this thom hoyle Excel Programming 14 May 11th 05 07:40 AM
Making code more efficient Tommi[_2_] Excel Programming 8 December 13th 03 07:47 PM


All times are GMT +1. The time now is 04:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"