Thread: Simpler Macro
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Joe via OfficeKB.com Joe via OfficeKB.com is offline
external usenet poster
 
Posts: 9
Default Simpler Macro

Ok the first macro looks for nothing but 123 which is great so it works. But
I wasn't sure on how to write the second one because it's not working the way
I planned, when the second macro runs it find's 123 then does a search for
CM3 (because it replaces the -2 charcters with the CM) and the crazy thing
it's finding matches!! which is incorrect. The whole reason I wanted the -2
is because there are other numbers like this XY456 and in our system it's
labled at CM456 so I figure just take two away with out thinking of the other
numbers without the letters in front. So I came up with this idea...I'm not
sure on how to write it though...

Susan wrote:
ok, joe
so the only thing that's different between the two macros is this area
of code?

i = Len(InvoiceNumber) 'count the characters in the string
i = i - 2 'Remove 1 from the count to accommodate YM, WM or XM
InvoiceNumber = Right(InvoiceNumber, i) 'counting back from the right
'select only the numbers

if your answer is yes, then you just need to devise some sort of if-
then test as to whether or not this section is performed.......
this is the only area where i could see you were deleting any
characters.
maybe this helps......
susan

Sub Zurnprt2()
Const SummaryWorkbook = "ZurnOpenItemsspreadsheet.xls"

[quoted text clipped - 60 lines]
--
Message posted viahttp://www.officekb.com


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200704/1