Results 1 to 10 of 10

Code VBA - command button update database

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2016
    Location
    Amsterdam
    MS-Off Ver
    2010
    Posts
    6

    Code VBA - command button update database

    hi all,
    I'm trying to build a time sheet database where each team member can fill in their time spent per week/day/project/project phase. I have build a worksheet for each member; they all look the same and include row 5:25 all projects and on columns I have Monday-Sunday (C4,E4,G4,I4,K4,M4,O4) and for each day a description cell where they can fill in the project phase from a drop-down list (D4,F4,H4,J4,L4,N4,P4). Above I have the team member name (A1) and end of week date (B2). Then I constructed a command button "Submit" which should transfer the data into a database sheet where I have the following headings: End of week, day, hours, project, project phase, team member (A2:F2) and which I want to be populated automatically when they click on the button.

    So far I have the following code but it returns only the first entry in the time-sheet, respectively the hours worked on Monday ("C4") on the first project ("B5").

    Do you know how to develop the code to look also into the following project lines (B6:B25) and to the following days (E4,G4,I4,K4,M4,O4)? Thanks so much!!

    Private Sub CommandButton1_Click()
    Dim Period As Date, Hours As Long, ProjectPhase As String, Day As String, Deal As String, TeamMember As String
    
    Worksheets("Johnny").Select
    Period = Range("b2")
    Hours = Range("C5")
    ProjectPhase = Range("D5")
    Day = Range("c4")
    Deal = Range("b5")
    TeamMember = Range("a1")
    
    
    Worksheets("Database").Select
    Worksheets("Database").Range("a2").Select
    If Worksheets("Database").Range("a2").Offset(1, 0) <> "" Then
    Worksheets("Database").Range("a2").End(x1Down).Offset(1, 0).Select
    End If
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Value = Period
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Day
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Hours
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Deal
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = ProjectPhase
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = TeamMember
    
    Worksheets("Johnny").Select
    Worksheets("Johnny").Range("C5:p25").ClearContents
    
    End Sub
    Last edited by VVex5; 08-07-2016 at 03:39 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  2. [SOLVED] Need to update database with Update button on userform
    By asoler in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2015, 08:13 PM
  3. [SOLVED] Run Command Prompt Icacls code in VBA Command Button on Userform
    By luismalave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2015, 11:40 PM
  4. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  5. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  6. [SOLVED] vba code, command bar, command bar button, one button works but not two
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 09:55 AM
  7. Automatically update existing data using a Update command button
    By 9999335 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2012, 09:46 PM

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