+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 16 of 16

Thread: Macro to select first cell under each heading

  1. #16
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,208

    Re: Macro to select first cell under each heading

    Since we are already passing the "job" variable from sub to sub in the other macros, we'll do the same here. Change this macro to accept the same parameter:
    Sub Add_TimeSheet(Job As String)
        Workbooks.Open Filename:= _
            "C:\Documents and Settings\colins\Desktop\ProjectManager\Timesheet.xlsm"
         
        Sheets("Timesheet").Copy After:=Sheets(1)
        Range("C3") = Response
        Range("C4") = Job
        
        ActiveSheet.Name = Response
        ActiveWorkbook.Save
        ActiveWindow.Close
    End Sub

    Then in the main index macro, add that parameter:
    Sub Add_Index(Job As String, Adj As Long)
        Response = Application.InputBox("Enter name of new employee", Type:=2)
        If Response = "False" Then Exit Sub
        
        Application.ScreenUpdating = False
            Call Add_BudgetDaily(Job)
            Call Add_Employee(Job)
            Call Add_Employee_Profile
            Call Add_Project_Schedule(Job, Adj) '2nd parameter is the offset from the title
            Call Add_Travel
            Call Add_TimeSheet(Job)
        Application.ScreenUpdating = True
    
    End Sub


    NOTE: For the sake of clarity reading this code, you should consider changing the name of the variable that holds the employee name entered from Response to EmpName so that it logically indicates what this variable holds. You would have to edit all the references to RESPONSE through the whole module, but it would be worth it.

    You could probably press CTRL-H and replace all the references at once...
    Last edited by JBeaucaire; 03-03-2010 at 08:03 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

+ 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.2.0