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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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