Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Extracting records from an excel list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon - 18 Jan 2006 23:50 GMT
I have a large spreadsheet with at least 6000 records (rows) and 5 columns.
The columns are as follows:

  B5           C5         D5     E5      F5
Check#  Vendor# Name Date Amount

From that  first sheet, I need to create separate worksheets that would
retrieve all the records (from column B to column F) belonging to a vendor
(NAME: D5)
For example, I would highlight one of the cells containing the vendor name,
launch the macro and it would create the worksheet, give it the vendor's name
then list all the records on the worksheet.

Any help with this project will be gratefully appreciated.

Thanks in advance
Rick Hansen - 19 Jan 2006 05:33 GMT
Hey Leon,

Try this, I beleve this is what your looking for. Select the Vendor Name in
Column "D" and run this macro. I use a command  button. Hope this helps.

 Rick , (Fbks, Ak)

Option Explicit

Sub NewNameSheet()

Dim main As Worksheet, wksNew As Worksheet
Dim lrc As Long
Dim Name As String
Dim ishCt As Integer        '' sheet count
Dim lnewRc As Long          '' row postion on new sheet

Set main = Worksheets("sheet1") '' main sheet
lrc = 6                            '' start row
Name = ActiveCell.Value

ishCt = Sheets.Count                        '' get number of worksheets
Worksheets.Add after:=Sheets(ishCt)              '' add new sheet
Worksheets.Item(ishCt + 1).Name = Name      '' rename sheet
Set wksNew = Worksheets(Name)

main.Range("B5:F5").Copy wksNew.Range("B5:F5")  '' copy header

lnewRc = 6                                  '' beginning row for records

'' search for Name of vendor, then Copy data to new sheet

Do Until IsEmpty(main.Cells(lrc, "D"))
  If main.Cells(lrc, "D") = Name Then
        '' Copy Vendor Data, & paste to new sheet
        main.Range("B" & lrc & ":F" & lrc).Copy wksNew.Range("B" & lnewRc &
":F" & lnewRc)
        lnewRc = lnewRc + 1
  End If
 lrc = lrc + 1         '' next row to search
Loop

End Sub

> I have a large spreadsheet with at least 6000 records (rows) and 5 columns.
> The columns are as follows:
[quoted text clipped - 12 lines]
>
> Thanks in advance
Leon - 19 Jan 2006 22:03 GMT
> Hey Leon,
>
[quoted text clipped - 61 lines]
>
> Hi Rick.

I'll try this right away and keep you posted

Thanks anyway.
Leon - 19 Jan 2006 22:11 GMT
> Hey Leon,
>
[quoted text clipped - 61 lines]
>
> Rick,
I get a "subscript out of range" on this line:
Set main = Worksheets("sheet1") '' main sheet

??
Rick Hansen - 20 Jan 2006 00:59 GMT
Hey Leon,
   Replace "Sheet1" with the name of your spreadsheet name that has all of
yours records ons.
Also don't have any blanks rows between your first and last record on your
main spreadsheet.
If you do it'll stop the search for names.  The "Isempty function is look
for the empty cell after the last record.
If you would like I'll email you my test spreadsheet program, here is my
email address rlhansen73@yahoo.com
Let me know if you need anymore help, Good Luck

  Rick

> > Hey Leon,
> >
[quoted text clipped - 65 lines]
>
> ??
Leon - 20 Jan 2006 20:30 GMT
It worked !

Thanks a lot.
By the way, I should have known to change "sheets1" into the name of my
source worksheet.

Thanks anyway I really appreciate your help

> Hey Leon,
>     Replace "Sheet1" with the name of your spreadsheet name that has all of
[quoted text clipped - 83 lines]
> >
> > ??
Rick Hansen - 20 Jan 2006 20:55 GMT
I'm glad I could help....

    Rick

> It worked !
>
[quoted text clipped - 91 lines]
> > >
> > > ??
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.