+ Reply to Thread
Results 1 to 3 of 3

click to copy cells and save sheet as

  1. #1
    Registered User
    Join Date
    11-30-2006
    Posts
    32

    click to copy cells and save sheet as

    Here's my problem:

    I have a excel check sheet with two columns (1 for apprvoved, 1 for not approved) each cell in these columns has a check box linked to it. I also have a date and a time control on the page.

    I have made a control button that when clicked I would like copy all the checked boxes (true cells) and paste a running tally of them on another page.

    I then want it to save only the sheet where the data was recorded in a folder with the name of the sheet followed by the date and time entered in those controls.

    Finally the macro should clear the check boxes save the "template workbook" and close.

    My VBA skills are rusty at best so I'm not sure how to even begin this.

    Any help???
    Thanks

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Jlong1980
    Here's my problem:

    I have a excel check sheet with two columns (1 for apprvoved, 1 for not approved) each cell in these columns has a check box linked to it. I also have a date and a time control on the page.

    I have made a control button that when clicked I would like copy all the checked boxes (true cells) and paste a running tally of them on another page.

    I then want it to save only the sheet where the data was recorded in a folder with the name of the sheet followed by the date and time entered in those controls.

    Finally the macro should clear the check boxes save the "template workbook" and close.

    My VBA skills are rusty at best so I'm not sure how to even begin this.

    Any help???
    Thanks
    Hi,

    That's some task you have set yourself.

    A good starting point would be to record a Macro and do the tasks as you expect them, a CountIf or SumProduct should provide your total (or you can Do Loop and total if), then Edit, Move or Copy Sheet, to New Book-Create a copy, then SaveAs and set the filename as required.
    Return to original worksheet, clear checkboxes and total, Save and close.

    That should provide the bulk of the code you require, you can then amend as required.

    Let me know how you go
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Registered User
    Join Date
    11-30-2006
    Posts
    32
    well so far I have the button to save sheets in the workbook as seperate files with the file name as sheetname + date/time stamp. It then closes the workbook without saving to clear everything leaving the original as a template...the problem is it seems to freeze up Excel and I can't figure out why. I still haven't gotten to the tally the checked cells in another sheet...tried a few things with no luck. Here is my code any suggestions are more than welcome.

    Option Explicit

    Sub MakeMultipleXLSfromWB()

    Dim CurWkbook As Workbook
    Dim wkSheet As Worksheet
    Dim newWkbook As Workbook
    Dim wkSheetName As String
    Dim shtcnt(3) As Long
    Dim xpathname As String, dtimestamp As String
    dtimestamp = Format(Now, "yyyymmdd_hhmmss")
    xpathname = "W:\2006 QA\Wall QA\Quickframe\Quickframe" & dtimestamp & "\"
    MkDir xpathname
    Set CurWkbook = Application.ActiveWorkbook

    shtcnt(2) = ActiveWorkbook.Sheets.Count
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    For Each wkSheet In CurWkbook.Worksheets
    shtcnt(1) = shtcnt(1) + 1

    Application.StatusBar = shtcnt(1) & "/" & shtcnt(2) & _
    " " & wkSheet.Name
    wkSheetName = Trim(wkSheet.Name)
    If wkSheetName = Left(Application.ActiveWorkbook.Name, _
    Len(Application.ActiveWorkbook.Name) - 4) Then _
    wkSheetName = wkSheetName & "_D" & dtimestamp
    Workbooks.Add
    ActiveWorkbook.SaveAs _
    Filename:=xpathname & wkSheetName & ".xls", _
    FileFormat:=xlNormal, Password:="", _
    WriteResPassword:="", CreateBackup:=False, _
    ReadOnlyRecommended:=True
    Set newWkbook = ActiveWorkbook

    Application.DisplayAlerts = False
    newWkbook.Worksheets("sheet1").Delete
    On Error Resume Next
    newWkbook.Worksheets(wkSheet.Name).Delete
    On Error GoTo 0
    Application.DisplayAlerts = True

    CurWkbook.Worksheets(wkSheet.Name).Copy Before:=newWkbook.Sheets(1)

    ActiveWorkbook.Save
    ActiveWorkbook.Close
    Next wkSheet
    Application.StatusBar = False
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.Interactive = False

    ActiveWorkbook.Saved = True
    ActiveWorkbook.Close


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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