Problem with FormulaR1C1 resulting in absolute reference

Jon Jagd

Board Regular
Joined
Jul 31, 2002
Messages
72
As You can see in the following VB code I will have a problem with the cell references made by the ForumulaR1C1 resulting in an absolute reference. The problem is that I want to drag the reference down in the cells below, and I want the column to be absolute but not the row.
Code:
ActiveCell.FormulaR1C1 = "='EKSP-REPORT-SHARE'!R" & tempRow & "C" & monthColumn
            Selection.AutoFill Destination:=Range(Cells(rangeStart, companyColumn), Cells(rangeEnd, companyColumn)), Type:=xlFillDefault

The formula makes af reference to another sheet and it looks like this ex:
Code:
='EKSP-REPORT-SHARE'!$L$5
And I guess what I want is, that the reference looks like this instead:
Code:
='EKSP-REPORT-SHARE'!$L5

Can I make FormulaR1C1 write this instead or do I have to change it afterwards?

Jon
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You are writing the formula using absolute reference. If you want relative reference, you'll have to write the formula that way:

Code:
temprow = temprow - activecell.row
monthColumn = monthColumn - ActiveCell.Column
ActiveCell.FormulaR1C1 = "='EKSP-REPORT-SHARE'!R[" & tempRow & "]C[" & monthColumn & "]"

You could put it into another set of temporary variables if you need to keep the original temps. Try this and see if it works. You might have to debug. I haven't tested this at all

Goblin
 
Upvote 0
Oops, just read you post again when I posted and saw that you wanted the column fixed as absolute. My modification made both column and row relative.

You'll figure it out :biggrin:

Goblin
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,209
Members
448,874
Latest member
b1step2far

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