Reference other Workbook Through Macro Trouble

TKB

Board Regular
Joined
Aug 18, 2011
Messages
128
Hello,

I am creating a macro that will automatically set cell A1 in the current workbook to cell A1 in another workbook through the following macro

ActiveCell.FormulaR1C1 = "='" & Stn & "\[" & NEmployee & ".xlsx]Sheet1'!A1"

While the formula does what it should, somewhere during the macro instead of reading:

='P:\TimeCards\[Rosa.xlsx]Sheet1'!A1

it reads like:

='P:\TimeCards\[Rosa.xlsx]Sheet1'!'A1'

I need to get rid of the ' highlighted in red and I don't know how to...

Is there a way to find those two ' and delete them?

Here is the surrounding code:

Code:
Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

Range("A1").Select


    ActiveCell.FormulaR1C1 = "='" & Stn & "\[" & NEmployee & ".xlsx]Sheet1'!A1"
    Range("A1").Select

'Then it just goes through and cleans up a bunch of non referenced cells
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,

removing the R1C1 stops the '!' but what the effect on your code is I don't know.

Code:
ActiveCell.Formula = "='" & Stn & "\[" & NEmployee & ".xlsx]Sheet1'!A1"
 
Upvote 0
yea, i have no idea why it was doing that. I had to go through and put the R & C for each cell :/. O well, i guess it at least works now... even tho its not very compact.

Thanks Deverunt!
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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