A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Formula Help



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2010, 09:55 AM posted to microsoft.public.excel.misc
Paula
external usenet poster
 
Posts: 278
Default Formula Help

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


  #2  
Old May 18th, 2010, 10:38 AM posted to microsoft.public.excel.misc
Mike H
external usenet poster
 
Posts: 8,419
Default Formula Help

Paula,

Are you ready for a Macro. Alt+F11 to open VB editor. Right click
'ThisWorkbook' and insert modula and paste the code below in.

Edit these 2 lines
Set sht = Sheets("Sheet1") ' change to suit
S = "France,Germany,Spain,UK" ' add as required

To the correct sheet and the correct countries. Add the necessaey countries
sperated by a comma and NO spaces. Run the code.


Sub Marine()
Dim R As Range
Dim V As Variant
Dim S As String
Dim CopyRange As Range
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "M").End(xlUp).Row
S = "France,Germany,Spain,UK" ' add as required
V = Split(S, ",")
For Each R In sht.Range("M1:M" & LastRow)
If IsError(Application.Match(CStr(R.Value), V, 0)) Then
If CopyRange Is Nothing Then
Set CopyRange = R.EntireRow
Else
Set CopyRange = Union(CopyRange, R.EntireRow)
End If
End If
Next R
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


  #3  
Old May 18th, 2010, 10:58 AM posted to microsoft.public.excel.misc
Paula
external usenet poster
 
Posts: 278
Default Formula Help

Hi Mike,

I am not very familiar with macros, well not at all, is there any way just
to do this with formula?

Regards

Paula


"Mike H" wrote:

Paula,

Are you ready for a Macro. Alt+F11 to open VB editor. Right click
'ThisWorkbook' and insert modula and paste the code below in.

Edit these 2 lines
Set sht = Sheets("Sheet1") ' change to suit
S = "France,Germany,Spain,UK" ' add as required

To the correct sheet and the correct countries. Add the necessaey countries
sperated by a comma and NO spaces. Run the code.


Sub Marine()
Dim R As Range
Dim V As Variant
Dim S As String
Dim CopyRange As Range
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "M").End(xlUp).Row
S = "France,Germany,Spain,UK" ' add as required
V = Split(S, ",")
For Each R In sht.Range("M1:M" & LastRow)
If IsError(Application.Match(CStr(R.Value), V, 0)) Then
If CopyRange Is Nothing Then
Set CopyRange = R.EntireRow
Else
Set CopyRange = Union(CopyRange, R.EntireRow)
End If
End If
Next R
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


  #4  
Old May 18th, 2010, 11:00 AM posted to microsoft.public.excel.misc
Paula
external usenet poster
 
Posts: 278
Default Formula Help

Hi Mike,

I'm not familiar with macros, is there any way to do this with formula?

Rgds Paula


"Mike H" wrote:

Paula,

Are you ready for a Macro. Alt+F11 to open VB editor. Right click
'ThisWorkbook' and insert modula and paste the code below in.

Edit these 2 lines
Set sht = Sheets("Sheet1") ' change to suit
S = "France,Germany,Spain,UK" ' add as required

To the correct sheet and the correct countries. Add the necessaey countries
sperated by a comma and NO spaces. Run the code.


Sub Marine()
Dim R As Range
Dim V As Variant
Dim S As String
Dim CopyRange As Range
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "M").End(xlUp).Row
S = "France,Germany,Spain,UK" ' add as required
V = Split(S, ",")
For Each R In sht.Range("M1:M" & LastRow)
If IsError(Application.Match(CStr(R.Value), V, 0)) Then
If CopyRange Is Nothing Then
Set CopyRange = R.EntireRow
Else
Set CopyRange = Union(CopyRange, R.EntireRow)
End If
End If
Next R
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


  #5  
Old May 18th, 2010, 11:01 AM posted to microsoft.public.excel.misc
Paula
external usenet poster
 
Posts: 278
Default Formula Help


Hi Mike

I am not familiar with macros, is there any way to do this with formulas?

Regards
Paula

"Mike H" wrote:

Paula,

Are you ready for a Macro. Alt+F11 to open VB editor. Right click
'ThisWorkbook' and insert modula and paste the code below in.

Edit these 2 lines
Set sht = Sheets("Sheet1") ' change to suit
S = "France,Germany,Spain,UK" ' add as required

To the correct sheet and the correct countries. Add the necessaey countries
sperated by a comma and NO spaces. Run the code.


Sub Marine()
Dim R As Range
Dim V As Variant
Dim S As String
Dim CopyRange As Range
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "M").End(xlUp).Row
S = "France,Germany,Spain,UK" ' add as required
V = Split(S, ",")
For Each R In sht.Range("M1:M" & LastRow)
If IsError(Application.Match(CStr(R.Value), V, 0)) Then
If CopyRange Is Nothing Then
Set CopyRange = R.EntireRow
Else
Set CopyRange = Union(CopyRange, R.EntireRow)
End If
End If
Next R
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


  #6  
Old May 18th, 2010, 11:18 AM posted to microsoft.public.excel.misc
Mike H
external usenet poster
 
Posts: 8,419
Default Formula Help

Paula,

A formula can't delete lines of data but we could try this. I put a list of
countries to keep in AA1 to AA9 and then put this formula in N1 and dragged
down

=IF(ISNA(VLOOKUP(M1,$AA$1:$AA$9,1,FALSE)),"Delete" ,"")

If the value in Col M isn't in your list in AA the the formula returns
DELETE. You can now sort the data on this column and manually delete the rows.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi Mike,

I am not very familiar with macros, well not at all, is there any way just
to do this with formula?

Regards

Paula


"Mike H" wrote:

Paula,

Are you ready for a Macro. Alt+F11 to open VB editor. Right click
'ThisWorkbook' and insert modula and paste the code below in.

Edit these 2 lines
Set sht = Sheets("Sheet1") ' change to suit
S = "France,Germany,Spain,UK" ' add as required

To the correct sheet and the correct countries. Add the necessaey countries
sperated by a comma and NO spaces. Run the code.


Sub Marine()
Dim R As Range
Dim V As Variant
Dim S As String
Dim CopyRange As Range
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "M").End(xlUp).Row
S = "France,Germany,Spain,UK" ' add as required
V = Split(S, ",")
For Each R In sht.Range("M1:M" & LastRow)
If IsError(Application.Match(CStr(R.Value), V, 0)) Then
If CopyRange Is Nothing Then
Set CopyRange = R.EntireRow
Else
Set CopyRange = Union(CopyRange, R.EntireRow)
End If
End If
Next R
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Paula" wrote:

Hi,

Hope you can help me, I have a report which I need to delete some lines of
data. The criteria is as follows:

Each record can have numerous lines of data and has a unique reference i.e.
MEBACI, however if this record contains any of 9 conditions in column M the
record should be left in full with no deleted lines of data.

However if the record does not contain any of the 9 conditions the entire
record should be deleted from the report.

The 9 conditions are Countires, e.g. UK, France, Germany etc.

Is there any formula which can be used to detect this?

Regards
Paula


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:26 PM.


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