Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
492 views
in Technique[技术] by (71.8m points)

excel - how to remove the link in VBA macro that is opening the file it was copied from, not the sheet in the current workbook?

I made a copied version from my main excel file (Facilities running) for my coworker to use the copied version is ( Automated Database). When I reassigned the macros buttons to be connected to Automated Database modules and I go and run the macros in my main excel file it redirects me to Automated Database copied Version. I tried that code I found on Stack overflow and it didn't cut the link. I want the macros to be assigned to the same workbook and not redirecting me to the other workbook.

Sub proper_text()
    Dim wb As Workbook
    Dim name_rng As Range
    Dim name_cell As Range
    Dim name_selection As String
Set wb = ActiveWorkbook
    With wb.Worksheets("Credentialing_Work_History")
        name_selection = getColRange("Company_Name")
        Set name_rng = Range(name_selection)
        For Each name_cell In name_rng
            name_cell.Value = WorksheetFunction.Proper(name_cell.Value)
        Next
    End With
End Sub

````
I also Tried that codes and still didn't work 
`````
Set wb = Workbooks("FACILITIES_DATABASE_RUNNING.xlsm")
    With wb.Worksheets("Credentialing_Work_History")
        name_selection = getColRange("Company_Name")
        Set name_rng = Range(name_selection)
        For Each name_cell In name_rng
            name_cell.Value = WorksheetFunction.Proper(name_cell.Value)
        Next
    End With
``````

Set wb = Workbooks("Facilities_Database_Automation.xlsm")
    With wb.Worksheets("Credentialing_Work_History")
        ' First Part
        name_selection = getColRange("Company_Name")
        Set name_rng = Range(name_selection)
        For Each name_cell In name_rng
            name_cell.Value = WorksheetFunction.Proper(name_cell.Value)
        Next
    End With

`` Still both of them linked not working.
question from:https://stackoverflow.com/questions/65943973/how-to-remove-the-link-in-vba-macro-that-is-opening-the-file-it-was-copied-from

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...