Insert Consecutive Numbers in the Middle Of Each Cell in a Sel
Holy Cow, Jacob! This so short and simple-looking. I'm not anywhere near the
skill level to have come up with this. I've learned a lot just looking at it.
A total eye-opener.
Thank you so much.
Kate
"Jacob Skaria" wrote:
Select the range to be converted and try the below macro;
Sub Macro()
Dim arrData As Variant, strData As String, intCount As Integer
For Each cell In Selection
If InStr(cell, "-") Then
arrData = Split(cell, "-")
If strData < arrData(0) Then intCount = 1
arrData(1) = intCount & "." & arrData(1)
cell.Value = Join(arrData, "-")
strData = arrData(0)
intCount = intCount + 1
End If
Next
End Sub
--
Jacob
"CitizenKate" wrote:
Hello,
I work with lists that look like this:
How To Build A Chair - Getting Started
How To Build A Chair - The Hard Part
How To Build A Chair - Cleaning Up
Forgotten Tales From Nova Scotia
When To Say No
Jack's Favorite Foods - Breakfast
Jack's Favorite Foods - Snacks
Jack's Favorite Foods - Drinks
Jack's Favorite Foods - Picnics
I want to build a macro that will allow me to select all the cells from the
same book, run the macro, and end up with this:
How To Build A Chair - 1. Getting Started
How To Build A Chair - 2. The Hard Part
How To Build A Chair - 3. Cleaning Up
Forgotten Tales From Nova Scotia
When To Say No
Jack's Favorite Foods - 1. Breakfast
Jack's Favorite Foods - 2. Snacks
Jack's Favorite Foods - 3. Drinks
Jack's Favorite Foods - 4. Picnics
I've recorded and written macros before, but never with any of the kinds of
variables and loops I think i'll need here. Any suggestions, advice or links
will be greatly appreciated.
Warmly,
CitizenKate
|