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 Question

I have a Macro that pulls data from a text file into a spreadsheet. I need
new to delete some rows that don't contain certain data.

Office Number for example. If the office number on my spreadsheet is not in
a list, I need to delete the row. I can use a loop, but my list has about
40 offices.

I tried using Lookup, but it doesn't quite work. I think my lookup command
is a little off, I only want to compare to one column, Column A in Office.

Here is the part of the code. I am deleting from the bottom up.

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
Test = Application.Lookup(Range("XY61!B" & Y),
Range("Office!$A$2:$A$84"), Range("Office!$A$2:$A$84"))
If IsError(Test) Then
Range("XY61!B" & Y).EntireRow.Delete
End If
Y = Y - 1
Loop

Thank you in advance.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Macro Question

You will need to loop through the data pulled in from the
text file to search for matches. Use the Find command to
search the 40 offices for a match to the cell in the text
data. If there is no match (can't find it) then delete
that row.

BOL
David C
-----Original Message-----
I have a Macro that pulls data from a text file into a

spreadsheet. I need
new to delete some rows that don't contain certain data.

Office Number for example. If the office number on my

spreadsheet is not in
a list, I need to delete the row. I can use a loop, but

my list has about
40 offices.

I tried using Lookup, but it doesn't quite work. I think

my lookup command
is a little off, I only want to compare to one column,

Column A in Office.

Here is the part of the code. I am deleting from the

bottom up.

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
Test = Application.Lookup(Range("XY61!B" & Y),
Range("Office!$A$2:$A$84"), Range("Office!$A$2:$A$84"))
If IsError(Test) Then
Range("XY61!B" & Y).EntireRow.Delete
End If
Y = Y - 1
Loop

Thank you in advance.



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro Question

Appreciate the answer, Find is not what I am looking for. I know I am close
with the formula. I already imported the data. I have the loop in place,
just need the formula for "Test" looked at.




"DavidC" wrote in message
...
You will need to loop through the data pulled in from the
text file to search for matches. Use the Find command to
search the 40 offices for a match to the cell in the text
data. If there is no match (can't find it) then delete
that row.

BOL
David C
-----Original Message-----
I have a Macro that pulls data from a text file into a

spreadsheet. I need
new to delete some rows that don't contain certain data.

Office Number for example. If the office number on my

spreadsheet is not in
a list, I need to delete the row. I can use a loop, but

my list has about
40 offices.

I tried using Lookup, but it doesn't quite work. I think

my lookup command
is a little off, I only want to compare to one column,

Column A in Office.

Here is the part of the code. I am deleting from the

bottom up.

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
Test = Application.Lookup(Range("XY61!B" & Y),
Range("Office!$A$2:$A$84"), Range("Office!$A$2:$A$84"))
If IsError(Test) Then
Range("XY61!B" & Y).EntireRow.Delete
End If
Y = Y - 1
Loop

Thank you in advance.



.



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro Question

Try this code it seems to do the job. It replaces your
test=....

Dim a As Integer, c As Variant

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
a = ActiveSheet.Range("xy61!B" & Y).Value
With Worksheets("office").Range("a2:a84")
Set c = .Find(a, LookIn:=xlValues)
If c Is Nothing Then
Range("XY61!B" & Y).EntireRow.Delete

Else

End If

End With

Y = Y - 1
Loop

BOL
DavidC

-----Original Message-----
Appreciate the answer, Find is not what I am looking

for. I know I am close
with the formula. I already imported the data. I have

the loop in place,
just need the formula for "Test" looked at.




"DavidC" wrote in

message
...
You will need to loop through the data pulled in from

the
text file to search for matches. Use the Find command

to
search the 40 offices for a match to the cell in the

text
data. If there is no match (can't find it) then delete
that row.

BOL
David C
-----Original Message-----
I have a Macro that pulls data from a text file into a

spreadsheet. I need
new to delete some rows that don't contain certain

data.

Office Number for example. If the office number on my

spreadsheet is not in
a list, I need to delete the row. I can use a loop,

but
my list has about
40 offices.

I tried using Lookup, but it doesn't quite work. I

think
my lookup command
is a little off, I only want to compare to one column,

Column A in Office.

Here is the part of the code. I am deleting from the

bottom up.

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
Test = Application.Lookup(Range("XY61!B" & Y),
Range("Office!$A$2:$A$84"), Range("Office!$A$2:$A$84"))
If IsError(Test) Then
Range("XY61!B" & Y).EntireRow.Delete
End If
Y = Y - 1
Loop

Thank you in advance.



.



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro Question

Aaaah. Now I get it.

Thanks David.


wrote in message
...
Try this code it seems to do the job. It replaces your
test=....

Dim a As Integer, c As Variant

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
a = ActiveSheet.Range("xy61!B" & Y).Value
With Worksheets("office").Range("a2:a84")
Set c = .Find(a, LookIn:=xlValues)
If c Is Nothing Then
Range("XY61!B" & Y).EntireRow.Delete

Else

End If

End With

Y = Y - 1
Loop

BOL
DavidC

-----Original Message-----
Appreciate the answer, Find is not what I am looking

for. I know I am close
with the formula. I already imported the data. I have

the loop in place,
just need the formula for "Test" looked at.




"DavidC" wrote in

message
...
You will need to loop through the data pulled in from

the
text file to search for matches. Use the Find command

to
search the 40 offices for a match to the cell in the

text
data. If there is no match (can't find it) then delete
that row.

BOL
David C
-----Original Message-----
I have a Macro that pulls data from a text file into a
spreadsheet. I need
new to delete some rows that don't contain certain

data.

Office Number for example. If the office number on my
spreadsheet is not in
a list, I need to delete the row. I can use a loop,

but
my list has about
40 offices.

I tried using Lookup, but it doesn't quite work. I

think
my lookup command
is a little off, I only want to compare to one column,
Column A in Office.

Here is the part of the code. I am deleting from the
bottom up.

Y = Range("XY61!A" & Rows.Count).End(xlUp).Row
Do While Y < 6
Test = Application.Lookup(Range("XY61!B" & Y),
Range("Office!$A$2:$A$84"), Range("Office!$A$2:$A$84"))
If IsError(Test) Then
Range("XY61!B" & Y).EntireRow.Delete
End If
Y = Y - 1
Loop

Thank you in advance.



.



.



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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
VB Macro question apache007 Excel Discussion (Misc queries) 2 August 13th 09 08:36 AM
Macro question Gilbert Excel Discussion (Misc queries) 7 November 8th 07 06:15 PM
question on macro Harry Excel Discussion (Misc queries) 8 April 13th 06 04:25 PM
macro question foamfollower Excel Programming 2 September 20th 03 02:04 AM


All times are GMT +1. The time now is 08:02 PM.

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"