+ Reply to Thread
Results 1 to 6 of 6

Loop for adding specific worksheets in specific workbooks

Hybrid View

  1. #1
    Registered User
    Join Date
    03-23-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    24

    Loop for adding specific worksheets in specific workbooks

    Hi All,


    Need your help on below scenario

    I have no. of values in one column...for ex. (1000)
    input box is given to decide the no. of worksheets. for ex. (50)

    Now I want to create first workbook for given no. of sheet (as per user input = 50)
    then create next workbook for next 50 values in column
    then next workbook...

    upto end of values in column (1000)

    so Total no. of workbooks would be 20 (1000/50)
    and total numbers of worksheets in each workbook will be 20.

    NOTE: below code is working fine for adding no. of sheets as per userinput, but getting hard to implement to workbook loop functionality

    can some one help please...

    Sub abc()
    Dim checktotalvalue
    Dim strvalue As Integer
    
    strvalue = InputBox(Prompt:="How many ODS you want in one file.", Title:="ENTER NUMBER OF ODS", Default:=20)
    If strvalue < 1 Then
               Exit Sub
    
    Else
    Dim countflag As Double
    
        ThisWorkbook.Sheets("object").Activate
        SaveODSDetails
    
    
        For a = 9 To (9 + strvalue) - 1
            If Not ThisWorkbook.Sheets("object").Cells(a, 1) = "" And ThisWorkbook.Sheets("object").Cells(a, 4).Value = "X" Then
                b = ThisWorkbook.Sheets("object").Cells(a, 1)
                ThisWorkbook.Sheets("ODS Detail").Copy Before:=ActiveWorkbook.Sheets(1)
                ActiveSheet.Name = b
                    Range("B2").Select
                    Range("B2").Value = b
                Call filldata
            End If
        Next a
    
        ActiveWorkbook.Close True
        countflag = Application.WorksheetFunction.CountIf((ThisWorkbook.Sheets("object").Range("D9:D1048576")), "X")
        MsgBox "New Workbook created for Objects"
    
    End If
    End Sub

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Loop for adding specific worksheets in specific workbooks

    I dont understand the logic. You said you have 1000 values in a column and those need to be divided as per the user input. So if the user enters 50, 50 sheets need to be created in each workbook, right? So each worksheet will have just 1 value from the main workbook

    Do you have a sample that you can upload?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    03-23-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Loop for adding specific worksheets in specific workbooks

    yes...the logic is same

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Loop for adding specific worksheets in specific workbooks

    Can you upload a sample please? The procedure to do so is given in post 2.

  5. #5
    Registered User
    Join Date
    03-23-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Loop for adding specific worksheets in specific workbooks

    Thank You...I got the answer...

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Loop for adding specific worksheets in specific workbooks

    What answer? Where?

+ 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. How to combine specific worksheets from different workbooks into one workbook?
    By thepulser89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2013, 03:44 AM
  2. Pasting data from MANY workbooks into specific worksheets of a master workbook
    By beemoney19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-17-2012, 11:30 PM
  3. Macro to extract data from multiple workbooks, specific sheet, specific cells
    By crissandraauree in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 03:54 PM
  4. How to loop through specific worksheets?
    By svenk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-11-2010, 12:15 PM
  5. Loop through specific worksheets
    By Ben in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2005, 10:40 AM

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