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


I was just wondering if there is possibly another way to do this. With
the code that i have it just seems to take forever...


I am using a form and when you put in a number in textboxNumber


the code goes to sheet1 and does the following

Sheet1.activate
Range("A2").select
Do
If csng(activecell) < csng(textboxNumber.value) then
activecell.offset(1,0).select
End if

Loop until csng(activecell) = csng(textboxNumber.value) or
activecell.row = 5000

activecell.offset(0,5).value = textboxOrderID
activecell.offset(0,6).value = textboxItemDescription


I would appreciate any ideas


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=558940

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Faster way to code this


You could use a find, eg:

[a2:a5000].find(what:=textboxNumber.value, lookat:=xlwhole).select

in place of the 'Do...Loop until'.

Col


--
colofnature
------------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
View this thread: http://www.excelforum.com/showthread...hreadid=558940

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Faster way to code this

Turn on the macro recorder. Select Column 1, Do edit=Find then type in the
number.

Turn off the macro recorder and look at the recorded code

Now modify this code to use the value in the textbox.

from
What:="1234"
to
What:=textboxNumber.value

you can also modify it to check for a found value

if application.Countif(Columns(1),textboxNumber.value ) 0 then
' modified recorded code
else
msgbox textboxNumber.Value & " is not in column 1"
end if



--
Regards,
Tom Ogilvy


"jhahes" wrote:


I was just wondering if there is possibly another way to do this. With
the code that i have it just seems to take forever...


I am using a form and when you put in a number in textboxNumber


the code goes to sheet1 and does the following

Sheet1.activate
Range("A2").select
Do
If csng(activecell) < csng(textboxNumber.value) then
activecell.offset(1,0).select
End if

Loop until csng(activecell) = csng(textboxNumber.value) or
activecell.row = 5000

activecell.offset(0,5).value = textboxOrderID
activecell.offset(0,6).value = textboxItemDescription


I would appreciate any ideas


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=558940


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Faster way to code this


thanks for the responses colofnature, and tom. I used the macro
recorder way and it works great.

Thanks


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=558940

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
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM
Which is faster code... Marcotte A Excel Programming 2 October 23rd 04 01:03 AM
Is there a faster way Jim May Excel Programming 3 September 19th 04 04:42 AM
Lag functions or faster code Frank Fuller Excel Programming 1 October 16th 03 05:17 PM
Could this code be faster? ste mac Excel Programming 2 August 27th 03 12:59 PM


All times are GMT +1. The time now is 03:01 AM.

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

About Us

"It's about Microsoft Excel"