Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 6th, 2008, 09:40 AM
RiciH83 RiciH83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 RiciH83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 36 sec
Reputation Power: 0
Help Splitting Data

I was wondering if anyone can help.

I currently have report i run and export into excel.

This data show alot of information. What i am wanting to do is automate a time consuming job and beeing a bit of a noob to vba struggling a bit.

Currently from this information is sort by a colum (eg Product number) which of course groups these together.

Then i have to manually create a new worksheet for each product number (rename the sheeet as the product number) and copy/paste information across.

Is there anyway of having a macro to automatically split the data for me into individual worksheets (and rename them)

Any help will be appreciated

Reply With Quote
  #2  
Old May 6th, 2008, 12:35 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,325 medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)  Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 3 Weeks 12 h 8 m 19 sec
Reputation Power: 2578
Sure. One thing you can do to start with is record a macro and do the steps manually then clean it up as reusable code after.

As for someone volunteering to write this for you from scratch I don't see that happening but its a fairly basic routine to write.
__________________
medialint.com

"Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context)

Reply With Quote
  #3  
Old May 6th, 2008, 04:07 PM
RiciH83 RiciH83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 RiciH83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by medialint
Sure. One thing you can do to start with is record a macro and do the steps manually then clean it up as reusable code after.

As for someone volunteering to write this for you from scratch I don't see that happening but its a fairly basic routine to write.


Thank you for a response,

i have tried that but the problem is as the data is use is not the same amounts ie one day there could be 1 of an order number and the next 50.

I unsure of how to do it, so that would be the reason im seeking some help or at least a push in the right direction.

Thank you

Reply With Quote
  #4  
Old May 6th, 2008, 10:08 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,325 medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)  Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 3 Weeks 12 h 8 m 19 sec
Reputation Power: 2578
What you're going to want to do is to make sure your data is sorted right and find the range to copy, then copy the range to a new worksheet. I'm afraid I don't have any practical examples on hand of this I can share but I'm sure there's some out there. There's probably a dozen ways you can implement to find the data range. A simple loop would be the easiest to implement but there's other ways using excel's built in functions.

The way I normally handle data splitting like this is to pipe it all into access then export queries back to excel which may seem like a lot of trouble but it has a lot of advantages depending on how much data you're dealing with and your ultimate goal.

Reply With Quote
  #5  
Old May 7th, 2008, 03:10 AM
RiciH83 RiciH83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 RiciH83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 36 sec
Reputation Power: 0
Thank you,

to be honest if i hadn't sorted this i was going to ditch excel and move it all across to access.

Just some colleagues who use the spreadsheet once i have updated are quite as comfortable with using Access compared with Excel.

Thank you

Reply With Quote
  #6  
Old May 7th, 2008, 06:01 AM
RiciH83 RiciH83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 RiciH83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 36 sec
Reputation Power: 0
Hi, thank you for those who showed some interest in helping but i managed to crack it in the end.

Here is code just incase someone else is looking for the same.

This code is taking into the fact that Headers are in Row 1

Thank you

Code:
Sub Test()
    Dim Sh As Worksheet
    Dim Rng As Range
    Dim c As Range
    Dim List As New Collection
    Dim Item As Variant
    Dim ShNew As Worksheet
    Application.ScreenUpdating = False
'   *** Change Sheet name to suit ***
    Set Sh = Worksheets("Transactions")
    Set Rng = Sh.Range("B2:B" & Sh.Range("B65536").End(xlUp).Row)
    On Error Resume Next
    For Each c In Rng
        List.Add c.Value, CStr(c.Value)
    Next c
    On Error GoTo 0
    Set Rng = Sh.Range("B1:L" & Sh.Range("B65536").End(xlUp).Row)
    For Each Item In List
        Set ShNew = Worksheets.Add
        ShNew.Name = Item
        Rng.AutoFilter Field:=1, Criteria1:=Item
        Rng.SpecialCells(xlCellTypeVisible).Copy ShNew.Range("A2")
        Rng.AutoFilter
    Next Item
    Sh.Activate
    Application.ScreenUpdating = True
End Sub 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Help Splitting Data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway