How to copy two cells and combine them to another cell using VBA .offset

NYRANGERS423

New Member
Joined
Mar 17, 2016
Messages
27
Ok so here is my scenario, I need to take Information from column B and column C and combine them to Column N. But what I am trying to do is not working. I am writing this
Target.Offset(0,12) = Target.Offset(0, 4) & Target.Offsey(0,5)
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this:

Code:
Sub Combine_Values()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row

    For i = 1 To Lastrow
        Cells(i, 14).Value = Cells(i, 2).Value & Cells(i, 3).Value
    Next

Application.ScreenUpdating = True
End Sub
 
Upvote 0
Ok so here is my scenario, I need to take Information from column B and column C and combine them to Column N. But what I am trying to do is not working. I am writing this
Target.Offset(0,12) = Target.Offset(0, 4) & Target.Offsey(0,5)
How are you trying to do that? The use of 'Target' indicates perhaps some worksheet 'event' is being used?

Note that Target.Offset(0,4) will never be column B as the 'Target' would need to off the left of the worksheet to be 4 columns to the left of column B.
 
Upvote 0
Try this:

Code:
Sub Combine_Values()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row

    For i = 1 To Lastrow
        Cells(i, 14).Value = Cells(i, 2).Value & Cells(i, 3).Value
    Next

Application.ScreenUpdating = True
End Sub

I modified the code a little bit and IT works great !!! Great help! Thank you.
 
Upvote 0
You could also consider filling in the whole column at once, rather than row-by-row.
Rich (BB code):
Sub Combine_Vals()
  With Range("N2:N" & Range("B" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate(.Offset(, -12).Address & "&" & .Offset(, -11).Address)
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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