Formula/Function to add a character in data column

IGinc

Board Regular
Joined
Jun 14, 2009
Messages
148
I have a DB Column G has Part #'s. When the DB was done (the J was not added, can someone help me with an automated solution formula or function, vba script, to insert J as the 5th character from cell G2-G1270. Thanks in advance.

Examples:

<table width="212" border="0" cellpadding="0" cellspacing="0"><col style="mso-width-source:userset;mso-width-alt:7753;width:159pt" width="212"> <tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:159pt" width="212" height="20">MO83JERHU-Acer-8-1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-4</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-5</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-6</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-7</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-8</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-9</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-10</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-11</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Acer-8-12</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Asus-8-13</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Asus-8-14</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">MO83ERHU-Asus-8-15</td> </tr> </tbody></table>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You could use this formula (copied down as needed) to create the corrected text, then Copy/Paste Special/Values over top of the existing data.

=LEFT(A1,4)&"J"&MID(A1,5,LEN(A1))

Alternately, if you were looking for a macro solution, select your cells (it is okay if you include blank cells in the selection) and run this...

Code:
Sub InsertJ()
  Dim Cell As Range
  For Each Cell In Selection
    If Len(Cell.Value) Then Cell.Value = Left(Cell, 4) & "J" & Mid(Cell.Value, 5, Len(Cell.Value))
  Next
End Sub
 
Last edited:
Upvote 0
Try

Code:
Sub AddJ()
Dim LR As Long, i As Long
LR = Range("G" & Rows.Count).End(xlUp).Row
For i = 2 To LR
    With Range("G" & i)
        If Mid(.Value, 5, 1) <> "J" Then
            .Value = Left(.Value, 4) & "J" & Right(.Value, Len(.Value) - 4)
        End If
    End With
Next i
End Sub
 
Upvote 0
Formula wise:

=REPLACE(G1,5,0,"J")

You could then copy and Paste Special Values over your original data.
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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