Hello everybody
I have data in Column A ..
Inside most of the cells not all I have slash
May be one slash or two or three or four
I need to remove any space before and after the slash ..
Note that the number of spaces are variable ..
Example : - Hello / Everybody This is /Just example/ to illustrate / my task .
The result should be like the following - Hello/Everybody This is/Just example/to illustrate/my task .
Note again the spaces before and after the slash only to be removed but other spaces remain as they are
Thanks advanced
7 3611 Rabbit 12,516
Recognized Expert Moderator MVP
Do you know VBA? You will need to create a custom function to do this. Off the top of my head, Use the Split() function to split it on the slash, Trim() each of the indexes in the resulting array, and then recombine the array into a string.
Thanks Mr. Rabbit for reply
Can you provide me the code or the UDF function that enables me do that task?
Rabbit 12,516
Recognized Expert Moderator MVP
Sorry, we don't usually write code for people. But if you attempt it yourself and post the code here, we can help troubleshoot it for you.
Ok Mr. Rabbit
Sorry I'm newbie here
Here's a code I tried to modify but I failed - Sub RemoveSpacesBeforeAfterSlash()
-
Dim A, I As Long, M As Object
-
With Cells(1).CurrentRegion.Resize(, 1)
-
A = .Value
-
With CreateObject("VBScript.RegExp")
-
.Global = True
-
.Pattern = "*( / *)?"
-
For I = 1 To UBound(A, 1)
-
If .test(A(I, 1)) Then A(I, 1) = _
-
.Replace(A(I, 1), "/")
-
Next
-
End With
-
.Value = A
-
End With
-
End Sub
-
Regards
Rabbit 12,516
Recognized Expert Moderator MVP
This doesn't look anything like what I suggested. I don't see the Split function nor the Trim function I mentioned.
And I didn't say anything about using regular expressions. While regular expressions are powerful and can do what you want, they are more complicated to use than my original suggestion.
Luuk 1,047
Recognized Expert Top Contributor
Indeed, regular expressions are complicated to use.
Use use: .Pattern = "*( / *)?" (Line#7)
It start with a "*", and according to some docs the "*" means:
"Matches the preceding element zero or more times"
So, without looking any further, your regular expression is wrong! ;)
Well... try starting with text to columns and then joining them again...as the no of slashes can vary, you will need to create some logic to loop through.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Danny |
last post by:
Given this:
"*"
the pattern to remove the htnl code between brackets, how can I remove a
series of spaces and just make one space.
like here is a series of blank spaces
thanks
|
by: BobM |
last post by:
I have two strings that I would like to compare. To guarantee the compare is
not affected by trailing spaces, I would like to remove them.
Will this do: MyTextBox.text.ToString().Trim()?
|
by: Paul |
last post by:
Hi just wondering if there is an easy way to remove spaces in a string, tried
the trim method but think it is only for leading or trailing spaces.
thanks
--
Paul G
Software engineer.
|
by: VK |
last post by:
If it was already answered somewhere, I'll be glad to be pointed to
(after the necessary comments on my search abilities :-)
I need as booletproof as possible way to strip out whitespaces from
between tag borders in the source code.
1) left border defined by gt sign >
2) right border defined by lt sign <
3) If the content between left and right borders consists only of white
spaces it has to be removed.
|
by: Bosconian |
last post by:
I know that
str.replace(/^\s+|\s+$/g,'');
will trim a string of space, but what about removing extra spaces from the
middle?
Where
"hello world"
| |
by: kamill |
last post by:
how can i remove blank spaces from text file......is there any function to remove a perticular chr from file...
|
by: hyperlez |
last post by:
Hey all
I have a column of user membership ids that is 8 characters long. These ids are based on the users surname with number added on the end to uniquely identify each user.
My problem is that if the users surname is short, there are spaces between the end of the surname and the numbers.
There are 18000 or so members in the database which is repopulated from the source database every night.
The reason that i am trying to do this...
|
by: buggtb |
last post by:
Hi Guys,
I've been given the joyous task of updating some very old scripts at work and I could do with a little help.
Our Unix system dumps text files to pseudo spoolers that our windows machines can then pick up and process. Now the guy who wrote one of the reports is obviously a bit clueless and the certain lines don't match up so for example our % line is a couple of spaces too far across.
A09
62371
__7.20%
|
by: SwapnilD |
last post by:
I'm implementing a feature which reads comma separated txt file from server(one line at a time).
Format of file is fixed, There are 3 columns on each row.
After reading the row from file I insert it in a database table.
But first value of each row aoutomatically appends two blank spaces, even if there are no blank spaces at the begining of each row.
I tried to use "TRIM/LTRIM/Replace" to remove blank spece from the first value of...
|
by: dev saini |
last post by:
how to remove number one by one in the calculator text box using JavaScript. its urgent
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |