vba R1C1 Formula Error.......

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
983
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,


Please assist to make R1C1 formula dynamic. Thanks
Below are my code my attempted Code.getting error at formula.




Sub R1C1_Dynamic()


Dim wbk As Workbook
Dim wsh As Worksheet
Dim mwbk As Workbook
Dim msh As Worksheet


Set mwbk = ThisWorkbook
Set msh = mwbk.Worksheets("Sheet1")


Set wbk = Workbooks.Open(msh.Range("c6").Value)
Set wsh = wbk.Worksheets("Sheet1")




Dim lr As Long
lr = wsh.Range("a1").CurrentRegion.Rows.Count


wsh.Activate
wsh.Range("d2:d"& lr).FormulaR1C1 = "=CONCATENATE((RC[-3]&" "&RC[-2]))"


End Sub

Thanks
Mallesh
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The issue is the double-quotes from the space in your formula is being interpretted as text qualifiers in the building of the formula.
To get literal double-quotes in the formula, you need to double them up, like this:
Code:
wsh.Range("d2:d" & lr).FormulaR1C1 = "=CONCATENATE((RC[-3]& "" ""&RC[-2]))"

Hint: The easy way to figure this out is to turn on your Macro Recorder, record yourself entering the formula on the worksheet, stopping the Macro Recorder, and viewing the code you just recorded to create that formula.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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