VBA help needed - For tiny adjustment to existing code

skyport

Active Member
Joined
Aug 3, 2014
Messages
374
This should be just a very minor change but I can't figure it out. Maybe someone can help. I am using an existing VBA code from a module that has worked perfectly so far. It concatenates columns A-G and puts the result in Column K. I want to keep the code doing exactly what it does performing the same features with no changes except have it put the result in column M instead of K. I tried changing the code myself by substituting the K factor in the code with M to accomplish this however, although it does concatenate to M instead of K, it does it with columns C-I instead of the A-G, which is needed. Please see code below:


Sub Concat()
Dim i As Long, LR As Long, j As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("K" & i)
.Value = .Offset(0, -10).Value & .Offset(0, -9).Value & .Offset(0, -8).Value & _
.Offset(0, -7).Value & .Offset(0, -6).Value & .Offset(0, -5).Value & .Offset(0, -4).Value


j = InStr(.Value, ". ")
.Characters(Start:=1, Length:=j).Font.Bold = True
End With
Next i
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hello Skyport,

I believe that you only need to adjust your offsets to allow for the fact that you are moving to the right another two columns.

Cheerio,
vcoolio.
 
Upvote 0
Sounds logical but I confess I don't know what I'm doing there. How would that appear in the actual code?
 
Upvote 0
Hello Skyport,

For example:-

Code:
.Offset(0, -10).Value

should change to:-

Code:
.Offset(0, -12).Value

etc., etc......

Just change the them all by 2.

Cheerio,
vcoolio.
 
Upvote 0
Hello Skyport,

You're welcome. Glad that I could help.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,618
Members
449,238
Latest member
wcbyers

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