hi,
there are numbers in different cells. how can I add a character to the beginning of these numbers easily.
for example
7665m007
7874dt33
2011kf85
will be
d7665m007
d7874dt33
d2011kf85
hi,
there are numbers in different cells. how can I add a character to the beginning of these numbers easily.
for example
7665m007
7874dt33
2011kf85
will be
d7665m007
d7874dt33
d2011kf85
OSMAN
paste the code in module & run
(pl change the sheet & range reference accordingly)
Sub addcharacter() Application.ScreenUpdating = False Dim iLastRow As Long Dim i As Long Dim addchar As String addchar = "d" '--Change as per requirement With Sheet1 '--Change as per requirement iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For i = iLastRow To 1 Step -1 .Cells(i, "A") = addchar & .Cells(i, "A") Next i End With Range("a1").Select Application.ScreenUpdating = True End Sub
Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
Practice this & save time of others in thinking for unsolved thread
Hi,
I tried but I get object required error. can you please check from the attached file
OSMAN
In a spare column enter ="d" & A1 and copy down. Copy/PasteSpecial Values over the original data and clear the helper column.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
No need to step backwards as you are not inserting/deleting rows.For i = iLastRow To 1 Step -1
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
hi,
if I want to add * symbol after 4 and delete k in g1204k
it will be g1204*. how can I do ?
OSMAN
Check out Replace in Help.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Just replace existing line with the below oneOriginally Posted by aoc
[VBA].Cells(i, "A") = addchar & Left(.Cells(i, "A"), Len(.Cells(i, "A")) - 1) & "*"[/VBA]
the above code first delete last 1 character then add given character on starting & asterisk (*) at the end
Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
Practice this & save time of others in thinking for unsolved thread
You could avoid looping. SeeOriginally Posted by anandbohra
HTHSub kTest() Dim r As Range, f As String Set r = Range("a1", Range("a" & Rows.Count).End(xlUp)) f = "=""D""&" & r.Address & "" With r .Value = Evaluate(f) End With End Sub
NeatOriginally Posted by Krishna Kumar
![]()
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'