Inserting formula into macro

John T

Board Regular
Joined
Nov 28, 2013
Messages
145
Office Version
  1. 365
Platform
  1. Windows
Hi, I have the following formula in cell N2

=I2&(" ")&J2&(" ")&K2


I2 Is a persons title
J2 is a persons initial
K2 is a persons surname

My formula combines them into one cell.
Is there a code that will type this in cell N2 and copy it down to the last row with data?
Ideally i then want columns I, J and K replaced with the data in column N. (usually i would paste special and delete columns I, J & K then insert column N into I).

Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
how about this

Sub test()

Dim i As Long, Lrow As Long
Lrow = Range("I1").CurrentRegion.Rows.Count

For i = 2 To Lrow
Cells(i, 14).Value = Cells(i, 9) & " " & Cells(i, 10) & " " & Cells(i, 11)
Next i
End Sub
 
Upvote 0
Solution
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
As you are using 365, you could also use
VBA Code:
Cells(i, 14).Value = Application.TextJoin(" ", , Cells(i, 9).Resize(, 3))
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,757
Members
448,991
Latest member
Hanakoro

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