VBA to continue through a specified range in the selected sheet

jamesaplant77

New Member
Joined
Apr 22, 2015
Messages
16
I am using this VBA to concatenate the contents of cells I2 and D2 into cell J2, one has a special character so I am using this code to ensure that the formatting remains. It works perfectly fine, but I have 836 rows of data in my workbook, so I need to ensure that the code continues until row 836, rater than just row 2 - I am hoping that this is relatively simple!!

Sub fconcat()


Application.ScreenUpdating = False
Sheets("ALL").Select
Range("J2").Value = Range("I2").Value & Range("D2").Value
For i = 1 To Range("I2").Characters.Count
Range("J2").Characters(i, 1).Font.Name = Range("I2").Characters(i, 1).Font.Name
Next
For i = 1 To Range("D2").Characters.Count
Range("J2").Characters(Range("I2").Characters.Count + i, 1).Font.Name = Range("D2").Characters(i, 1).Font.Name
Next
Application.ScreenUpdating = True
End Sub
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
Try this:
Code:
    Dim myRow As Long

    Application.ScreenUpdating = False

    Sheets("ALL").Select
    For myRow = 2 To 836
        Range("J" & myRow).Value = Range("I" & myRow).Value & Range("D" & myRow).Value
        For i = 1 To Range("I" & myRow).Characters.Count
            Range("J" & myRow).Characters(i, 1).Font.Name = Range("I" & myRow).Characters(i, 1).Font.Name
        Next
        For i = 1 To Range("D" & myRow).Characters.Count
            Range("J" & myRow).Characters(Range("I" & myRow).Characters.Count + i, 1).Font.Name = Range("D" & myRow).Characters(i, 1).Font.Name
        Next
    Next myRow
    
    Application.ScreenUpdating = True
 

Watch MrExcel Video

Forum statistics

Threads
1,122,569
Messages
5,596,918
Members
414,110
Latest member
docops

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