Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Populate Project name on new worksheets

Posted on 2014-07-24
7
116 Views
Last Modified: 2014-07-24
Folks,
 I have two workbooks where one workbook (""Consolidated") is appended by new tabs from another workbook ("Append").
Once everything is in updated the user enters in a Project Name in cell S2 of the "Consolidated" workbook and selects "Populated Project Name". That's where I have a problem. The "Populate Project Name" is a form control assigned to a macro labeled "ProjectName". This module,"ProjectName, is hard coded in that only tabs with a year ending in 14 for each month works. I'm needing a way to populate each monthly worksheet with the Project Name, which is in T2:V2 (the cells are merged), regardless of the year.
Consolidated.xlsm
Append.xlsm
0
Comment
Question by:Frank Freese
  • 4
  • 3
7 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40218147
Change your ProjectName macro to this and the user only has to click the button (no manual entry in S2:S4) so you can remove the instructions in V2.

Sub ProjectName()

    Dim strName As String
    Dim sht As Worksheet
    
    strName = InputBox("Please enter the project name")
    
    For Each sht In Worksheets
        If sht.Name = "Consolidated" Then
            sht.Range("S2").Value = strName
        Else
            sht.Range("T2") = strName
        End If
    Next
    
End Sub

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 40218169
Perfect
Thanks
0
 

Author Closing Comment

by:Frank Freese
ID: 40218172
Again, you nailed it!
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 40218181
YW. As you've seen, recording macros is often a very unsatisfactory way of adding code.
0
 

Author Comment

by:Frank Freese
ID: 40218200
Agreed. It does help some in how things need to be written, just as long as you haven't restricted yourself like I have. I use them sometime to jump start myself.
I'm pulling away from ActiveX controls going forward as much as possible with form controls.
Finally, they have approved the workbooks so I'm sending out the finals now with all the little corrections and additions.
Thank you so very much for all your help here.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40218214
I'm happy that you're done with this but I'm surprised that they don't want some things protected or some things hidden like people's hourly rates.
0
 

Author Comment

by:Frank Freese
ID: 40218225
They've decided to do that themselves, protecting the worksheets. They've been put on notice that cells with formulas had better be protected.
Regarding the rates. On the last "Consolidated" they took those off.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question