Thread: Simpler Macro
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default Simpler Macro

Both are similiar the other one just doesn't take away two characters

so, not really, because one is searching for things & the other one
isn't......

why don't you post BOTH macro codes.
label one "THIS ONE RUNS FIRST"
and the other "THIS ONE RUNS SECOND"

then i (or anybody else) can see exactly what you're trying to do, in
the order you're trying to do it in.

finding incorrect matches, it only finds what you tell it to. so
there must be some kind of error in telling it what you want it to
find.
:)
susan



On Apr 17, 1:12 pm, "Joe via OfficeKB.com" <u27679@uwe wrote:
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.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200704/1- Hide quoted text -

- Show quoted text -