Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Code please for incrementing text. For instance:
Text "D01-003" is in E7 and I need "D01-004" in E11 The following works but results in "D01-4" but I must maintain the "000" format of the right three characters which need to go beyond "100" Sub test() Cells(11, 5) = Left(Cells(7, 5), 4) & (Right(Cells(7, 5), 3) + 1) End Sub Many thanks - in anticipation. Francis Hookham |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The function you're looking for is Format().
I'd use: Cells(11, 5).Value = Left(Cells(7, 5).Value, 4) _ & Format(Mid(Cells(7, 5).Value, 5) + 1, "000") With Mid(), you can just specify the starting position and xl's VBA will take the rest of the string. (Different from the =mid() worksheet function.) Francis Hookham wrote: Code please for incrementing text. For instance: Text "D01-003" is in E7 and I need "D01-004" in E11 The following works but results in "D01-4" but I must maintain the "000" format of the right three characters which need to go beyond "100" Sub test() Cells(11, 5) = Left(Cells(7, 5), 4) & (Right(Cells(7, 5), 3) + 1) End Sub Many thanks - in anticipation. Francis Hookham -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Many thanks, especially the Mid() tip - I did not know.
"Dave Peterson" wrote in message ... The function you're looking for is Format(). I'd use: Cells(11, 5).Value = Left(Cells(7, 5).Value, 4) _ & Format(Mid(Cells(7, 5).Value, 5) + 1, "000") With Mid(), you can just specify the starting position and xl's VBA will take the rest of the string. (Different from the =mid() worksheet function.) Francis Hookham wrote: Code please for incrementing text. For instance: Text "D01-003" is in E7 and I need "D01-004" in E11 The following works but results in "D01-4" but I must maintain the "000" format of the right three characters which need to go beyond "100" Sub test() Cells(11, 5) = Left(Cells(7, 5), 4) & (Right(Cells(7, 5), 3) + 1) End Sub Many thanks - in anticipation. Francis Hookham -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using TEXT and &TEXT - display numbers with commas, underline text | Excel Discussion (Misc queries) | |||
Text does not display in "Text boxs" and when wrapping text in a c | Excel Discussion (Misc queries) | |||
select text in cell based on text from another cell, paste the text at the begining of a thrid cell, etc... | Excel Programming | |||
Excel VBA: Worksheet cell .Text property: 1024 bytes text len limit | Excel Programming | |||
extracting text from within a cell - 'text to rows@ equivalent of 'text to columns' | Excel Programming |