#1




VBA code for adding slash (/)
Hi, I'm needing some help to solve my problem:
1. As you see below, each section of line is separated by slash sign (/) 2. The problem is sometimes I forget to add slash or make mistakes by adding other codes, ex: comas (,), space ( ), etc. If I check them back and fix them one by one, it require a lot of time and there's still chance to lose them. I'm wondering for any help in this problem. I need VBA code for adding slash at the end of each section: after (x)+number or dot (.)+numbers of each section Would you mind to help me? Any help would be great. SAMPLE DATA *note: ^t > tab character Quote:
Regards, Jasa Last edited by Jasa P; 05082012 at 01:07 AM. 
#2




Hi Jasa,
What is the logic that the code would use to determine where to put the slash if you've left it out? Your examples seem to show the slashes being preceded by one or two digits after the 'x' or '.', sometimes both on the same line.
__________________
Cheers, Paul Edstein [Fmr MS MVP  Word] 
#3




Hi Paul, thank you for your reply. And I'm so sorry, I made mistake of writing Excel.. The correct one is Word 2007.
Yeah! It's confusing, how to make the logic conditions about this problem. Huff. ~`~ First, I want to let you know (x) is multiplication. But, dot (.) is sum My data is processed in Word. I'm using 2 macro: First macro is for replacing some characters that are unwanted (record macro) Second macro is for lowering capital (X) and changing (x) after first (x) to dot (.) (the one you gave me) And this one is gonna be the third Then, the data is processed in Excel. I'm using 1 macro: This macro is for sum the multiplications, ex: 10.20.30x10/ > the result is 30 235.458.101x25.20/ > the result is 135 1120.1135x10/ > the result is 20 So, numbers before (x) is counted by the sum of dot (.)+1 >(first result) Number/s after (x) is counted by the sum of numbers between (x) and slash (/) >(second result) The final result is multiplication of first and second result There are 3 ways for possible numbers before (x) 2 numbers/+dot(.), ex: 01 or 45 etc 3 numbers/+dot(.), ex: 245 or 939 etc 4 numbers/+dot(.), ex: 1174 or 8364 etc If we limit the use of summing numbers after (x). So, there are just 4 for each section, can we solve this problem? Possible sum after (x) For 2 numbers before (x) > 1 sum For 3 numbers before (x) > 1 or 2 sum For 4 numbers before (x) > 1 or 2 or 3 sum Thank you Paul Regards, Jasa 
#4




Hi Jasa,
That's all very well, but it doesn't answer the question I asked: What is the logic that the code would use to determine where to put the slash if you've left it out?
__________________
Cheers, Paul Edstein [Fmr MS MVP  Word] 
#5




If I already added a slash (/) then by adding this macro there would be 2 slash (/), isn't it?
Can we use a macro to find and replace multiple slashes with a slash? Thank you Paul 
#6




Hi Jasa,
I have moved the post to the Word vba forum. It is easy enough to make sure only one slash gets inserted, but you still haven't answered the basic question: Quote:
S01=02^t45.01.39.05x245.201.939.905.01.45.39.05.37 .73/01.30.66.00.28.64x74.45.5.10 how does the code know it should be that and not: S01=02^t45.01.39.05x245.201.939.905.01.45.39.05.37 .730/1.30.66.00.28.64x74.45.5.10 or: S01=02^t45.01.39.05x245.201.939.905.01.45.39.05.37 .7/301.30.66.00.28.64x74.45.5.10 or even something else, such as: S01=02^t45.01.39.05x245.201.93/9.905.01.45.39.05.37 .7301.30.66.00.28.64x74.45.5.10
__________________
Cheers, Paul Edstein [Fmr MS MVP  Word] 
#7




Quote:
Well, I'm still confused about that one. I need time to think about it. Would you mind? I'll tell you as soon as I possible. Sorry for this delay, Paul. Thank you for helping me.. have a great time Regards, Jasa 
Tags 
macro, vba, vba word 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Where does my code go?  rbaldwin  Word VBA  3  03142012 02:31 PM 
vbc code  rajpeter  Excel Programming  2  09132011 02:29 PM 
Word07Bid Tab Code  ddw23  Word VBA  0  07282011 01:07 PM 
Adding Image into a excel cell and adding a hyperlink to the image  saravananiyyanar  Excel  3  05042011 08:31 AM 
A slash shows up before bookmarks  Hunter  Word  0  03072010 05:57 AM 