Macro recording

Dolemitefunk

New Member
Joined
Oct 12, 2010
Messages
47
I am trying to create a macro that will open anther workbook, select the sheet, go to a specific cell and set that cell equal to the original worksheet the marco is being made on. I have tried to create this by recording and have a few questions about the code.

ActiveCell.FormulaR1C1 = "='[Testing.xlsm]Sheet1'!R[12]C[-5]"

I do not understand what this line is doing, it looks like it is selecting the cell by moving it from a reference point, how would I make it so it picks a specific cell?

I hope this makes sense, any feedback would be greatly appreciated
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
When recording a macro, you have a choice of using relative references. I use XL 07 and can click the 'Use Relative References' button after starting to record the macro. The line you have is a reference to the row and column of the cell you selected in the file called Testing. It may help to record the macro without Relative References option selected.

ActiveCell.FormulaR1C1 = "='[Testing.xlsm]Sheet1'!R[12]C[-5]"
 
Upvote 0
ActiveCell.FormulaR1C1 = "='[Testing.xlsm]Sheet1'!R[17]C[-5]"

I tried recording the macro again, and got this same line. I made sure the reference button was off. Is there a way to change this code to pick Cell C31 in the Testing.xlsm Worksheet?
 
Upvote 0
Sorry I sent you in the wrong direction yesterday. The formula within the macro will always use the R1C1 reference. However, if you'd like the formula to always appear in a specific cell, the following may help:

Cells.Range("A3").FormulaR1C1 = "=R[-2]C+R[-1]C"

This line of code will insert the formula =A1+A2 into cell A3

Hope this helps.

jim
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,812
Members
452,945
Latest member
Bib195

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