How to change a relative cell address row, Ex: "=RC[1]&RC[2]" to absolute address in a do loop

jkalpus

New Member
Joined
Apr 17, 2004
Messages
46
Greetings. I need to concatenate two cells using VBA, but keep ONE of those cell address absolute (the R[1].
I also need to have the code loop through the cells until finished.
Here's what I've got so far.

Do
ActiveCell.FormulaR1C1 = "=RC[1]&RC[2]"
ActiveCell.Offset(1, 0).Range("A1").Select

Loop Until IsEmpty(ActiveCell.Offset(0, 2)) = True

I've tried simply removing the [] which I thought turns the cell address into absolute. It's not working.
What, please, am I missing here??? I'm using Excel 2013.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,182
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Depending whre Activecell is to start with, you wiil need to change it to...
so assuming activecell is in row 1, it will be
Code:
ActiveCell.Formula = "=B1&C1"

Might be better to post ALL the code !
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,646
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Greetings. I need to concatenate two cells using VBA, but keep ONE of those cell address absolute (the R[1].
I also need to have the code loop through the cells until finished.
Here's what I've got so far.

Do
ActiveCell.FormulaR1C1 = "=RC[1]&RC[2]"
ActiveCell.Offset(1, 0).Range("A1").Select

Loop Until IsEmpty(ActiveCell.Offset(0, 2)) = True

I've tried simply removing the [] which I thought turns the cell address into absolute. It's not working.
What, please, am I missing here??? I'm using Excel 2013.
The square brackets are an offset from the reference cell which, in your case is the ActiveCell wherever that may be, so removing the square brackets ignores the ActiveCell reference and fixes the location at Columns A and B. I think this will place the correct formula in the ActiveCell for you...

ActiveCell.FormulaR1C1 = "=RC" & ActiveCell.Column + 1 & "&RC" & ActiveCell.Column + 2
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,263
Messages
5,769,117
Members
425,518
Latest member
seothaeng

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
Top