+ Reply to Thread
Results 1 to 7 of 7

add additional IF statement then split sheets further...

  1. #1
    Registered User
    Join Date
    08-16-2016
    Location
    Sydney
    MS-Off Ver
    2013 PP
    Posts
    4

    add additional IF statement then split sheets further...

    Hi guys,
    Having a bit of trouble working out where it put it.


    So the following, takes a block of Cells, and separates them based on unique values in column 9.
    It then creates new tabs with each unqiue value in 9, and then it creates new worksheets also containing those filtered cells, based on column 9.
    An example piece of data, has 3000 rows, and 8 unique values in column 9.

    I want to add: If counta of a filtered value is >300 then divide by 2 and split those between two sheets; so say the unique value was "Hotel", then you would have "Hotel Sheet 1" & "Hotel Sheet 2".
    If >600, then divide by 3 and split those between three sheets. >900, split between 4 sheets. (that should be enough).

    Any thoughts? Appreciate the help!!!!!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,406

    Re: add additional IF statement then split sheets further...

    Try this macro:


    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 08-16-2016 at 03:55 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    08-16-2016
    Location
    Sydney
    MS-Off Ver
    2013 PP
    Posts
    4

    Re: add additional IF statement then split sheets further...

    Hi there, thanks heaps for your help.

    I have modified it further - to try and grab anything that is going to be split, to actually halve/third/quater it.

    But I am getting an error here:

    shtB.Range("A2").Resize((SplR - 1) * (i - 1)).EntireRow.Delete

    So then I added the round functions into the SplR section, but then that didn't quite work, so then I defined it up front as '150' but then it gave me sheets in 150 chunks - suggesting that my attempt to split into equal parts, simply doesn't work.

    If you could help me out with that logic, that would be great. I basically replaced "lngMRows" with "SplR", but the syntax on the calculations might be wrong.

    Thanks!


    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,406

    Re: add additional IF statement then split sheets further...

    If the sheet needs to be split, this will split it evenly:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-16-2016
    Location
    Sydney
    MS-Off Ver
    2013 PP
    Posts
    4

    Re: add additional IF statement then split sheets further...

    Hey Bernie,

    Thank you for that.

    I am getting a "1004 error" Method "Name" of obejct '_worksheet' failed.
    Referring to: shtT.Name = c.Value

    The code I used is exactly the same as your laste, aside from: (lCol = 27)
    I had to use =trim(left(A7,7)) to get the uniquiness of the strings to what I wanted.

    Any thoughts?

    -=-=-

    Thanks for the code!

    I think it was because i didn't have a value in the header row of that column 27!
    All good.
    Last edited by yeders; 09-06-2016 at 09:50 PM.

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,406

    Re: add additional IF statement then split sheets further...

    Does the "All good" mean that you figured out the problem, or do you still need help?

  7. #7
    Registered User
    Join Date
    08-16-2016
    Location
    Sydney
    MS-Off Ver
    2013 PP
    Posts
    4

    Re: add additional IF statement then split sheets further...

    Hi Bernie,
    Sorry - "all good" means that I sorted it out, no more help necessary (for now :D). I think it was because i was missing some column headers.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] If statement using contains with an additional qualifier
    By tisimp14 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2016, 01:32 PM
  2. Need Macro code to split data split in 7 sheets based on variable rows in column A
    By Alija_21 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2015, 08:03 AM
  3. [SOLVED] Additional IF Statement - Help!
    By mack_76 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-27-2015, 07:06 AM
  4. [SOLVED] Additional problem related to 1016964-split-of-data-into-seperate-rows-using-a-date-range
    By ploppmongo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2014, 07:10 AM
  5. [SOLVED] Multiple IF statement with additional requirements
    By Clash in forum Excel General
    Replies: 3
    Last Post: 11-01-2012, 10:35 AM
  6. [SOLVED] Split Macro modification to Split into new Workbooks instead of sheets within one workbook
    By DLSmith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2012, 08:11 PM
  7. Adding additional IF statement
    By rhudgins in forum Excel General
    Replies: 1
    Last Post: 04-13-2010, 04:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1