If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Change names

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-09-10, 14:18
nogoodnames nogoodnames is offline
Registered User
 
Join Date: Mar 2010
Posts: 27
Change names

I have a workbook that has MANY external links to other workbooks on 8 different worksheets.

All of the other workbooks are of the same name format: John Stats , Bill Stats , etc.

Right now, all links work by looking for 'John Stats'A1 etc. However, if John leaves, and is replaced by Mary... it's a big nightmare.

Any ideas for a macro button I could put in that would allow me to 'change names' really easily?

In a perfect world, the macro would be started and say 'who do you want to replace?' and pull up a list of the current people. Choose one of them and then 'what name do you want to replace XXXX with?'. Type the new name (Mary), and now Mary's stats are tracked on the workbook called Mary Stats and John Stats is not tracked at all.

I hope that makes sense, and if that's extremely difficult, I'm open to suggestions.

Thanks in advance!!!!
Reply With Quote
  #2 (permalink)  
Old 06-09-10, 14:43
nogoodnames nogoodnames is offline
Registered User
 
Join Date: Mar 2010
Posts: 27
Ok, I've figured this one out (quite easy after all!).
Reply With Quote
  #3 (permalink)  
Old 06-09-10, 16:04
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Out of interest, what did you do?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #4 (permalink)  
Old 06-09-10, 16:43
nogoodnames nogoodnames is offline
Registered User
 
Join Date: Mar 2010
Posts: 27
Nothing all that fancy:


Code:
Sub Name_Change()
'
' Name_Change Macro
'

'
    Dim OldName As String
    Dim NewName As String
    OldName = InputBox("What name do you want to replace?", _
        "Who do you want to replace?", "Enter Name")

    If OldName = "Enter Name" Or _
    OldName = "" Then
    Exit Sub
    End If
    
    NewName = InputBox("What is the new name?", _
        "Who is the new person?", "Enter Name")
    If NewName = "Enter Name" Or _
    NewName = "" Then
    Exit Sub
    End If
    
    i = MsgBox("Replace " & OldName & " with " & NewName & "?", vbOK)
    Select Case i
        Case vbOK
            j = MsgBox("Are you sure?", vbOKCancel)
            Case vbCancel
                Exit Sub
        Case vbCancel
            Exit Sub
    End Select
    
    Sheets(Array("Monday Totals", "Tuesday Totals", "Wednesday Totals", _
        "Thursday Totals", "Friday Totals", "Saturday Totals", "Weekly Totals")).Select
    Sheets("Monday Totals").Activate
    Cells.Select
    Selection.Replace What:=OldName, Replacement:=NewName, LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Sheets("Weekly Totals").Select
    Range("A1").Select
End Sub

But it works and is effective.

If you've got a better/tidier suggestion, fire away.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On