Results 1 to 9 of 9

Need a macro to update data from raw file to individual sheets of master

Threaded View

  1. #1
    Registered User
    Join Date
    10-23-2011
    Location
    Delhi
    MS-Off Ver
    Excel 2007
    Posts
    5

    Exclamation Need a macro to update data from raw file to individual sheets of master

    Hi Everyone,

    I need a code for the following steps to be enacted

    1. Save a backup file with the name counts - date.xls (this will be a
    daily file)
    2. remove rows with name (column B) matching with name in to be
    removed sheet
    3. copy value in name field and open the corusponding sheet in the
    master
    4. once the sheet is active, go to the last row insert current date in
    left most collumn and paste the row from raw to master (from Column B)
    5. copy the formula in the remailing columns in that sheet from above
    6. once updated give a msg = this work is now complete

    Conditions -
    1. If the sheet does not exist in the master then give an inputbox
    informing that we have a new name and asking if a new sheet should be
    created or should this be merged with another existing sheet - if user
    says yes to new sheet then create a new one with the same headers/
    formatting and formulas as the others
    2. In the end in the msg box (this work is now complete) it should
    contain a summary of unusual events i.e.
    A. New name (sheet created)
    B. New name (merged with existing sheet)
    C. Count for particular name in Column C2 greater than 50 (Name-
    column B and count - C2 detail)

    I tried my hand on this but got stuck half way. i was not able to find
    a way to put condition 3 in the code.

    This is really urgent ....I would be really really really greatful if
    someone can help me out here.

    Thanks a lot

    I have attached a sample file for test and master with this post along
    with my code.

    Code:
    Sub Counts_upload()
    '
    ' Counts_upload Macro
    ' This macro is used to load running counts from raw to master workbook
    ' Keyboard Shortcut: Ctrl+Shift+A
       Workbooks("test").Sheets("raw").Select
        Range("A1").Select
        Dim i As Integer
        last = Cells(Rows.Count, "B").End(xlUp).Row
        For i = last To 1 Step -1
            If (Cells(i, "B").Value) = "ABC" Then
                Cells(i, "A").EntireRow.Delete
            End If
            If (Cells(i, "B").Value) = "XYZ" Then
                Cells(i, "A").EntireRow.Delete
            End If
            If (Cells(i, "B").Value) = "Res" Then
                Cells(i, "A").EntireRow.Delete
            End If
            Next i
        ChDir "C:\Desktop\counts"
        Dim flname As Long
        ActiveWorkbook.SaveCopyAs "C:\Desktop\counts\counts - " & Format(Date, "dd-mmm-yy") & ".xls"
        Workbooks("test").Sheets("raw").Select
        Dim k As Integer
        Dim wrk As Worksheet
        Dim n As Integer
        Dim countnonblank As Integer
        Dim myRange As Range
        Set myRange = Columns("B:B")
        countnonblank = Application.WorksheetFunction.CountA(myRange)
        n = countnonblank
        For k = 2 To n Step 1
        wrk = Worksheets("raw").Range("B" & k).Value
        Worksheets("raw").Cells(k, "A").EntireRow.Copy
        If k = "" Then
        Exit Sub
        End If
        Worksheets(wrk).Range("A1").selct
        activecell.End(xlDown).Select
        activecell.Offset(1, 0).Select
        activecell.Value = Date
        activecell.Offset(0, 1).Select
        activecell.PasteSpecial
        Next k
        End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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