External workbook

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
609
Office Version
  1. 2019
Platform
  1. Windows
Greetings, I have been using this code to change a shape color and it works fine, but now instead of the same workbook/worksheet I would like to source it from a different workbook. I am having trouble referencing that second workbook, every one I have tried has errored out. So I am thinking that the problem is my syntax. Could anyone show me the syntax to get it to reference the following workbook? Thank you

"'L:\CommonRW\[FacilitiesApps.xlsm]Coding'!$E7"


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Intersect(Target, Range("F7")) Is Nothing Then Exit Sub
    If IsNumeric(Target.Value) Then
        If Target.Value = 3 Then
            ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor.RGB = vbRed
        ElseIf Target.Value = 2 Then
            ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor.RGB = vbYellow
        Else
            ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor.RGB = vbGreen
        End If
    End If
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi Rick,
what are you trying to achieve? Pick up the value of E7 in that external file? Or do you want to change something in the current workbook when something gets changed in the external workbook?
Cheers,
Koen
 
Upvote 0
Hi Rick,
what are you trying to achieve? Pick up the value of E7 in that external file? Or do you want to change something in the current workbook when something gets changed in the external workbook?
Cheers,
Koen

Hi Rijnsent - I am trying to update the active workbook from the values of the second workbook on the server, so that a shape fill color will change based on the cell value from the external worksheet. (In this workbook I have a sub that is "refreshing the data" every 30 minutes by opening/closing all of the external workbooks).

Typically I use hyperlinks and just bring the data into a "coding"' worksheet in the same workbook that I use to keep all of the data synced up. If I was changing cell colors then I could just use conditional formatting to do that, but now I am trying to change the shape colors. I have a sub that can do this based on a cell value, but I don't believe that it will work because the reference cell actually has the hyperlink in it, and not just the returned cell value.

I realize that the worksheet change event may not trigger the change, but I thought I would try this first and then tweak the trigger after I got all of my references lined up. This code works fine in the same sheet, it just stops working if I put it on my second sheet or another workbook. Right now it appears that the typical workbook/worksheet style syntax is not correct because I get errors, so I thought I would start with that and get it correct first.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top