vba R1C1 Formula Error.......

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
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 does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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