convert a formula R1C1 to formula of A1 format

roypogo

New Member
Joined
Jul 3, 2017
Messages
20
How can I convert a formula R1C1 to formula of A1 format.

I have a formula as:
Worksheets("View Data").Range("D2").FormulaR1C1 = "=MID(Data!RC[" & Var1 & "],(LEN(Data!RC[" & Var1 & "])-9),9)"

to

Worksheets("View Data").Range("D2").Formula = "=MID(Data!F2,(LEN(Data!F2)-9),9)"

the column F will be dynamically generated from Var1.

Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Which column will the formula be going in?
 
Upvote 0
Which column will the formula in column D look at?

PS R1C1 formulas are easier to work with when columns are dynamic.
 
Upvote 0
The formula will look at a variable column. I tried with the below code as:
Sheets("Data").Activate
Set NM1L = ActiveSheet.UsedRange.Find("NM1*IL*1 - Member Name", , xlValues, xlWhole)
NM1L1 = NM1L.Column - 1
MsgBox NM1L.Column.Address
Worksheets("View Data").Range("D2").FormulaR1C1 = "=MID(Data!RC[" & NM1L1 & "],(LEN(Data!RC[" & NM1L1 & "])-9),9)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D" & lRow), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("D2:D" & lRow), Type:=xlFillDefault
Range("D2:D" & lRow).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

But I am unable to get the desired result.

Actually the formula is trying to find the column in Work sheet "Data" where the header is NM1*IL*1 - Member Name. Let us say it is column F.
In Another Worksheet "View Data" in column D it will be doing a MID function of F2.

But when use my above formula instead of F2 the Mid Function is getting applied to I2 as =MID(Data!I2,(LEN(Data!I2)-9),9) instead of =MID(Data!F2,(LEN(Data!F2)-9),9)

Any help is greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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