Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add character to text 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I need to add a hyphen in the 6th character to a column of data. I have 232 cells in this column.
My code does not give me any errors but it also does not insert anything. Any help would be appreciated.


Code:
Sub dashSN()
'

Dim myString As String

' dashSN Macro
'
For i = 2 To 232
       Cells(i, 1).Select
    myString = "-"
   Midwords = Mid(myString, 6, 7)
    
Next i
'
    
End Sub
 
hi,
Code:
Sub dashSN()
    Dim i
    Const myString = "-"
    
    ' dashSN Macro
    '
    For i = 2 To 4
        With Cells(i, 1)
            .Value = Mid(.Value, 1, 5) & myString & Mid(.Value, 6)
        End With
    Next i
    '
End Sub

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top