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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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