Activity Stream
48,167 MEMBERS
6821 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member
    Website's:
    facebook.com

    Exclamation VBA: Add Specific Cell Values to Table in Existing Workbook?? (HELP)

    Hey guyz,

    I am having a little trouble and would like some help.

    I have a template worksheet in excel with payroll information.

    This template is used for all employees.

    Now I want to create a button that copies certain cell values (Name, date, total, etc) and adds them to a table in a separate existing workbook. In other words it would be a summary of the payroll.

    I want it to add the information in the next empty row in the table, so it would keep old info.


    Anyone have anything for me??

    Thank you!
    cotufa-ssdd Reviewed by cotufa-ssdd on . VBA: Add Specific Cell Values to Table in Existing Workbook?? (HELP) Hey guyz, I am having a little trouble and would like some help. I have a template worksheet in excel with payroll information. This template is used for all employees. Now I want to create a button that copies certain cell values (Name, date, total, etc) and adds them to a table in a separate existing workbook. In other words it would be a summary of the payroll. Rating: 5
    All right everyone, line up alphabetically according to your height.

  2.   Sponsored Links

  3.     
    #2
    I r Super Cop
    why not use pivot table? its pretty simple

    if your requirement IS what you asked above - writing macros would do the job, im not aware of it but yes, ive seen it being used in my company.
    Follow besthostingforums on FB

    Looking for an Article Writer? Check out my services here.

  4.     
    #3
    Member
    Website's:
    facebook.com
    figured it out, tought i would share it...

    Code: 
    Option Explicit
    Sub TransferData()
        Dim wkb As Workbook, wks As Worksheet, LastRow As Long
        Dim FilePath As String, FileName As String
        Dim ws As Worksheet, blnOpened As Boolean
        FilePath = "C:\test" 'change path here
        FileName = "Book2.xls" 'change name here
        Call ToggleEvents(False)
        Set ws = ThisWorkbook.Sheets("Sheet1") 'source sheet
        If WbOpen(FileName) = True Then
            Set wkb = Workbooks(FileName)
            blnOpened = False
        Else
            If Right(FilePath, 1) <> Application.PathSeparator Then
                FilePath = FilePath & Application.PathSeparator
            End If
            Set wkb = Workbooks.Open(FilePath & FileName)
            blnOpened = True
        End If
        Set wks = wkb.Sheets("Sheet1") 'destination sheet name
        LastRow = wks.Cells.Find(what:="*", after:=wks.Cells(1, 1), searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1
        wks.Cells(LastRow, "A").Value = ws.Cells(1, "B").Value
        wks.Cells(LastRow, "B").Value = ws.Cells(4, "B").Value
        wks.Cells(LastRow, "C").Value = ws.Cells(7, "B").Value
        wks.Cells(LastRow, "D").Value = ws.Cells(7, "E").Value
        If blnOpened = True Then
            wkb.Close SaveChanges:=True
        End If
        If MsgBox("Clear values?", vbYesNo, "CLEAR?") = vbYes Then
            Call ClearData
        End If
        Call ToggleEvents(True)
    End Sub
    Sub ClearData()
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Sheets("Sheet1")
        ws.Range("B1").ClearContents 'Name
        ws.Range("B4").ClearContents 'Address
        ws.Range("B7").ClearContents 'Age
        ws.Range("E7").ClearContents 'Sex
    End Sub
    Sub ToggleEvents(blnState As Boolean)
        With Application
            .DisplayAlerts = blnState
            .EnableEvents = blnState
            .ScreenUpdating = blnState
            If blnState Then .CutCopyMode = False
            If blnState Then .StatusBar = False
        End With
    End Sub
    Function WbOpen(wbName As String) As Boolean
        On Error Resume Next
        WbOpen = Len(Workbooks(wbName).Name)
    End Function
    thnx for opinion Rox...
    All right everyone, line up alphabetically according to your height.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Not Existing link redirect to Main URL
    By Rizwan Saleem in forum Wordpress
    Replies: 1
    Last Post: 8th Nov 2011, 01:32 PM
  2. Search Mod for Existing Topic?!
    By Deadmau5 in forum vBulletin
    Replies: 6
    Last Post: 10th Aug 2011, 08:29 PM
  3. google crawler poting values on my site WTF ?
    By cgworld in forum Webmaster Discussion
    Replies: 27
    Last Post: 4th Jan 2011, 12:52 AM
  4. [Help] Javascript for coping values to clipboard ?
    By Snell in forum Web Development Area
    Replies: 4
    Last Post: 16th Nov 2010, 09:30 AM
  5. Installing dle on existing databse
    By janu123 in forum Webmaster Discussion
    Replies: 18
    Last Post: 8th Oct 2010, 06:08 AM

Tags for this Thread

BE SOCIAL