Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro - delete row if cell contains string

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1 www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macro - delete row if cell contains string

You could use a helper column with formulas like:

=isnumber(search("/",a2))

Then drag it down the column.

Then apply data|filter|autofilter to that column.
Show the Trues and delete those visible rows.

wrote:

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1
www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macro - delete row if cell contains string

Sub hij()
Dim i As Long, j As Long, s As String
i = 1
Do While Not IsEmpty(Cells(i, 1))
If InStr(1, Cells(i, 1), "/", vbTextCompare) = 0 Then
s = Cells(i, 1)
j = i + 1
Do While InStr(1, Cells(j, 1), s, vbTextCompare) < 0
j = j + 1
Loop
Range(Cells(i, 1), Cells(j - 1, 1)).EntireRow.Delete
Else
i = i + 1
End If
Loop
End Sub

worked for me with your data.

--
Regards,
Tom Ogilvy



" wrote:

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1 www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default macro - delete row if cell contains string

You can try something similar to this:
Dim rng As Range
Columns("A:A").Select
For Each rng In Selection
rng.Activate
If ActiveCell.Value < "" And InStr(1, ActiveCell.Value, "/") = 0 Then
ActiveCell.Delete (xlShiftUp)
ActiveCell.Offset(1, 0).Activate
End If
Next

" wrote:

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1 www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro - delete row if cell contains string

Thanks dave,
It works great for the top level domains,
But I need to be able to delete the files of the domains it deletes
too.
Any Idea how i can do that too?
Alex



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macro - delete row if cell contains string

Sub hij()
Dim i As Long, j As Long, s As String
i = 1
Do While Not IsEmpty(Cells(i, 1))
If InStr(1, Cells(i, 1), "/", vbTextCompare) = 0 Then
s = Cells(i, 1)
j = i + 1
Do While InStr(1, Cells(j, 1), s, vbTextCompare) < 0
j = j + 1
Loop
Range(Cells(i, 1), Cells(j - 1, 1)).EntireRow.Delete
Else
i = i + 1
End If
Loop
End Sub

worked for me with your data.

--
Regards,
Tom Ogilvy



" wrote:

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1 www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro - delete row if cell contains string

sorry jim,
I dont seem to be able to get that to work, it deleted about 10 of them
but left the rest, i cant seem to work out why.
alex

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro - delete row if cell contains string

the data is availible online to view in an xls at
http://www.hottubs2buy.co.uk/10.xls
thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macro - delete row if cell contains string

How do you read it?

a
a/b
c/d
e
e/f

delete everything but c/d as I understood it.

--
Regards,
Tom Ogilvy


"Dave Peterson" wrote:

You could use a helper column with formulas like:

=isnumber(search("/",a2))

Then drag it down the column.

Then apply data|filter|autofilter to that column.
Show the Trues and delete those visible rows.

wrote:

Hi all,

Can some one help me please!
Here is a slightly more complex macro that I really need. I have a list
of domain names in excel for example:

1
www.throneofnails.com
2 www.throneofnails.com/info/index.html
3 www.fairkess.com/en/business/industrie.html
4 www.endlessdecor.com/Links.html
5 www.retractableawnings.com/resources.htm
6 www.ffbd-tm.com
7 www.ffbd-tm.com/test

I need a macro that will delete all the top level domain names eg
www.throneofnails.com and delete all files in that domain eg
www.throneofnails.com/info/index.html.

I need to be left with a list of only domain names like domain name 3,4
and 5.

I think it will probably have something to do with finding the cells
that dont contain a "/" then loading them into an array then deleting
all cells that contain the contents of that array.

Unfortunately I dont have the programing language to do this.

Your help would be much appreciated.

Many thanks

Alex Kemsley


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro - delete row if cell contains string

thats right tony,
you got it!
Alex



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macro - delete row if cell contains string

I posted a tested macro that does exactly that, but I guess you don't want to
use it.

--
Regards,
Tom Ogilvy



" wrote:

thats right tony,
you got it!
Alex


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro - delete row if cell contains string

Looks like a ploy to open a web page of advertising set up to look like a
404 error.

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
the data is availible online to view in an xls at
http://www.hottubs2buy.co.uk/10.xls
thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro syntax to check string length in a cell El Bee Excel Discussion (Misc queries) 3 November 1st 06 09:13 PM
How can delete the duplicate word from a string in cell in EXCEL Laxman A Patil Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
How do I delete part of a text string in every cell it appears in Chacky Excel Discussion (Misc queries) 3 December 9th 05 07:06 PM
A Macro to replace a string in a cell with a string from another cell??? Plica05 Excel Programming 2 August 16th 05 09:23 AM
Macro to delete last charcter in a text string Brian Excel Programming 2 July 24th 03 03:43 AM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"