ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please Help..Neeed VBA code to delete information in a cell (https://www.excelbanter.com/excel-programming/360954-please-help-neeed-vba-code-delete-information-cell.html)

Shani

Please Help..Neeed VBA code to delete information in a cell
 
I need to delete information in cell

for example if A2= http://google.com/help/you/me

I want to remove everything after "com"

So i would want A2 = http://google.com


Joe[_42_]

Please Help..Neeed VBA code to delete information in a cell
 
Do you know beforehand what kind of entries you would be having in the
range you are considering? eg: is this all going to be
www.site.com/blah/blah, or could it be just about anything - john,
ring.tones, http://mysearch, etc ?

Joe.


vqthomf

Please Help..Neeed VBA code to delete information in a cell
 
The only way that know is this you can try it.
Regards
Charles

Sub test()
'
Dim myString As String, myString2 As String
myString = Range("A2").Value
myString2 = Mid(myString, 1, InStr(InStr(InStr(myString, "/") + 1,
myString, "/") + 1, myString, "/") - 1)

End Sub


"Shani" wrote:

I need to delete information in cell

for example if A2= http://google.com/help/you/me

I want to remove everything after "com"

So i would want A2 = http://google.com



Shani

Please Help..Neeed VBA code to delete information in a cell
 
Yes Joe all the entries will be www.site.com/blah/blah


Wendell A. Clark

Please Help..Neeed VBA code to delete information in a cell
 
I would include the the whole 'com\'

such as

Sub test()
'
Dim myString As String, myString2 As String
myString = Range("A2").Value
myString2 = Mid(myString, 1, InStr(InStr(InStr(myString, "com/") + 4,
myString, "/") + 1, myString, "/") - 1)

End Sub

that way you could assure it was after the com and avoid mistakes at the
http:// portion (if applicable)

--
Wendell A. Clark, BS
-------------------------------------

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may
contain confidential and privileged information for the use of the
designated recipients named above. If you are not the intended recipient,
please notify us by reply e-mail. You are hereby notified that you have
received this communication in error and that any review, disclosure,
dissemination, distribution or copying of it or its contents is prohibited.
If you have received this communication in error, please destroy all copies
of this communication and any attachments. Contact the sender if it
continues.


"vqthomf" wrote in message
...
The only way that know is this you can try it.
Regards
Charles

Sub test()
'
Dim myString As String, myString2 As String
myString = Range("A2").Value
myString2 = Mid(myString, 1, InStr(InStr(InStr(myString, "/") + 1,
myString, "/") + 1, myString, "/") - 1)

End Sub


"Shani" wrote:

I need to delete information in cell

for example if A2= http://google.com/help/you/me

I want to remove everything after "com"

So i would want A2 = http://google.com





Joe[_42_]

Please Help..Neeed VBA code to delete information in a cell
 
I havent yet tried the two codes that are posted here, but by the looks
of it, it should work. And in case you havent done it before, you can
have the code running for the whole column by following this logic:

Define a starting cell:

eg: define myrange = A2

Use a "Do while not isempty(myrange)

(enter your filtering code here)

Set myrange = myrange.offset(1,0)

Loop

The offset(1,0) would move your range down by one row. If you had used
offset (0,1) , it would have taken you one cell to the right in the
same row. and the loop as defined above would have the filter running
on A2, A3, A4, etc until it hits a blank cell entry.

Hope this helps.

Joe.



All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com