Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2012, 02:02 AM
Jasa P Jasa P is offline VBA code for adding slash (/) Windows XP VBA code for adding slash (/) Office 2007
Novice
VBA code for adding slash (/)
 
Join Date: Apr 2012
Posts: 13
Jasa P is on a distinguished road
Default 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:
S01=02^t45.01.39.05x245.201.939.905.01.45.39.05.37 .73/01.30.66.00.28.64x74.45.5.10




L01=03^t0266x2/2066x2/6066x2/6766x2/266x3/066x3/766x3/66x10/15x5/51x5/11x5/16x5/516x5/99x5


L02=04^t06x5.60.5.2.5/20x5.5.5.50.5.3.3


B01=05^t62.58.75.85.26.08.80.45.42x2.54.72.15.299. 8.15.63.57.5/50x7.56.45.30.90.4/06.76.16.86.24x4/439.39x6/49.94.15.51x100


B02=07^t29.92.26.62.36.63.46.64.59x3.95.6/278.295.241.277x244.248.2/78.95.85.41.77.44x4.53.2/578.578.539x2/78.76.39x4/13.25.52.28.82.18.81x6
I'm using Word 2007, Windows XP for PC, and Windows 7 for notebook


Regards,



Jasa

Last edited by Jasa P; 05-08-2012 at 01:07 AM.
Reply With Quote
  #2  
Old 05-07-2012, 03:49 AM
macropod's Avatar
macropod macropod is offline VBA code for adding slash (/) Windows 7 64bit VBA code for adding slash (/) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 05-08-2012, 01:05 AM
Jasa P Jasa P is offline VBA code for adding slash (/) Windows XP VBA code for adding slash (/) Office 2007
Novice
VBA code for adding slash (/)
 
Join Date: Apr 2012
Posts: 13
Jasa P is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 05-08-2012, 01:29 AM
macropod's Avatar
macropod macropod is offline VBA code for adding slash (/) Windows 7 64bit VBA code for adding slash (/) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 05-08-2012, 01:43 AM
Jasa P Jasa P is offline VBA code for adding slash (/) Windows XP VBA code for adding slash (/) Office 2007
Novice
VBA code for adding slash (/)
 
Join Date: Apr 2012
Posts: 13
Jasa P is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 05-08-2012, 01:55 AM
macropod's Avatar
macropod macropod is offline VBA code for adding slash (/) Windows 7 64bit VBA code for adding slash (/) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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:
What is the logic that the code would use to determine where to put the slash if you've left it out?
Until you answer that, no solution is possible. For example, with your first string:
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]
Reply With Quote
  #7  
Old 05-09-2012, 10:12 AM
Jasa P Jasa P is offline VBA code for adding slash (/) Windows XP VBA code for adding slash (/) Office 2007
Novice
VBA code for adding slash (/)
 
Join Date: Apr 2012
Posts: 13
Jasa P is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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:

Until you answer that, no solution is possible. For example, with your first string:
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
Hi, Paul

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
Reply With Quote
Reply

Tags
macro, vba, vba word



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code for adding slash (/) Where does my code go? rbaldwin Word VBA 3 03-14-2012 02:31 PM
VBA code for adding slash (/) vbc code rajpeter Excel Programming 2 09-13-2011 02:29 PM
Word07-Bid Tab Code ddw23 Word VBA 0 07-28-2011 01:07 PM
VBA code for adding slash (/) Adding Image into a excel cell and adding a hyperlink to the image saravananiyyanar Excel 3 05-04-2011 08:31 AM
A slash shows up before bookmarks Hunter Word 0 03-07-2010 05:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft