Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default check row in other document

Hi all!
I have a document with a row that contains names of some custumers. They are
writen down many times so there are multiple entries. I need another document
to check the first row of that document and display the name of the first
customer folowed by the second etc... but I don't want to display the same
customer twice. Is this possible? Do I need VBA code for this?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default check row in other document

Look at Chip Pearson's page on Uniques and Duplicates

http://www.cpearson.com/excel/duplicat.htm

--
Regards,
Tom Ogilvy


"Calle" wrote in message
...
Hi all!
I have a document with a row that contains names of some custumers. They
are
writen down many times so there are multiple entries. I need another
document
to check the first row of that document and display the name of the first
customer folowed by the second etc... but I don't want to display the same
customer twice. Is this possible? Do I need VBA code for this?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default check row in other document

Thanks Tom! This helps. However do you have a code for looking up columns in
other documents/workbooks...

"Tom Ogilvy" wrote:

Look at Chip Pearson's page on Uniques and Duplicates

http://www.cpearson.com/excel/duplicat.htm

--
Regards,
Tom Ogilvy


"Calle" wrote in message
...
Hi all!
I have a document with a row that contains names of some custumers. They
are
writen down many times so there are multiple entries. I need another
document
to check the first row of that document and display the name of the first
customer folowed by the second etc... but I don't want to display the same
customer twice. Is this possible? Do I need VBA code for this?

Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default check row in other document

Sub EFG()
Dim noDupes as Collection
Dim item, swap1, swap2, cell as Range, rng as Range
Dim i as Long, j as Long
Dim col as long
set noDupes = New Collection
' duplicate names in row1 of Sheet1 of workbook named Otherbook.xls
with workbooks("otherbook.xls").Worksheets("sheet1")
set rng = .Range(.Range("A1"),.Range("A1").End(xltoRight))
End with

for each cell in rng
On Error Resume next
nodupes.add cell.Value, cell.Text
On Error goto 0
Next

' sort the unique names
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, befo=j
NoDupes.Add Swap2, befo=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i

' write them out to row 1 of activesheet

Col = 1
For Each Item In NoDupes
Activesheet.Cells(1,col) = Item
col = col + 1
Next Item

End Sub

Much of the code taken from John Walkenbach's site:
http://j-walk.com/ss/excel/tips/tip47.htm

Code is untested and may contain typos.

--
regards,
Tom Ogilvy




"Calle" wrote in message
...
Thanks Tom! This helps. However do you have a code for looking up columns
in
other documents/workbooks...

"Tom Ogilvy" wrote:

Look at Chip Pearson's page on Uniques and Duplicates

http://www.cpearson.com/excel/duplicat.htm

--
Regards,
Tom Ogilvy


"Calle" wrote in message
...
Hi all!
I have a document with a row that contains names of some custumers.
They
are
writen down many times so there are multiple entries. I need another
document
to check the first row of that document and display the name of the
first
customer folowed by the second etc... but I don't want to display the
same
customer twice. Is this possible? Do I need VBA code for this?

Thanks in advance.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default check row in other document

Hi Tom!
That code works if I have the list in the same workbook but when I have it
in a differesnt document I get an error message (" The index is out of the
interval") well it's in swedish but I think it's translated something like
that....


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default check row in other document

with workbooks("otherbook.xls").Worksheets("sheet1")
set rng = .Range(.Range("A1"),.Range("A1").End(xltoRight))
End with

specifies it uses the otherbook.xls sheet1 row 1 to gather the information
(a workbook other than the activeworkbook). The error (subscript out of
Range) would mean you are not giving the correct name for the workbook or it
isn't open or you are not naming the correct worksheet. The workbook must
be open and you can't put in a string like "C:\MyFolder\Otherbook.xls" as
an additional caution.

--
Regards,
Tom Ogilvy


"Calle" wrote in message
...
Hi Tom!
That code works if I have the list in the same workbook but when I have it
in a differesnt document I get an error message (" The index is out of the
interval") well it's in swedish but I think it's translated something like
that....



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
Spell Check on Excel document Michele Excel Discussion (Misc queries) 2 February 9th 10 08:30 PM
how do i check if i have printed a document in excel and when petergod New Users to Excel 0 December 4th 09 05:09 PM
Check if a document is open AnthonyJ Excel Programming 3 September 29th 06 03:15 PM
How do I put a check mark box in an excel document form? Albert Excel Discussion (Misc queries) 2 July 7th 06 05:14 PM
spell check protected document Sportingspaniel Excel Discussion (Misc queries) 1 January 10th 05 11:40 AM


All times are GMT +1. The time now is 03:46 AM.

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

About Us

"It's about Microsoft Excel"