VBA Code using RC

gnt21

New Member
Joined
Mar 26, 2025
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Very new to VBA and unsure what the code is supposed to return. So I'm looking for experts help to say in plain english what should be returned in this scenario:

BookA.Sheets("Results").Range("AE2").FormulaR1C31 = "=TRIM(RC[" & Rein_Trty_Col - 1 & "])"

I'm trying to alter an existing workbook to handle a new situation. I really appreciate any help. Thanks!
 
Your code should be
Excel Formula:
FormulaR1C1
not
Rich (BB code):
FormulaR1C31

You have not told us the meaning of variable Rein_Trty_Col. The way it is used here, the [brackets] indicate that it is a relative column reference. If Rein_Trty_Col is 10, for example, the resulting R1C1 formula will be
=TRIM(RC[9])
That means "same row as the cell with this formula, and 9 columns to the right"

You are putting this formula in AE2, so that example formula will look like this once it is put in the cell:
Excel Formula:
=TRIM(AN2)

In reality AN is going to be whatever column that is (Rein_Trty_Col - 1) columns to the right of column AE.
 
Upvote 0
Solution
Much appreciated. Now I know what to be looking for and how to adjust as needed.
 
Upvote 0

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