Here is my sheet:
Excel 2007
This macro gets me really close except I don't know how to increment the _01 to _02:
Sub InsertRowWithContentsAboveAndAutoIncrementDocNumber()
Dim X As String
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1).EntireRow.Insert Shift:=xlDown
X = ActiveCell.Offset(-1, 0).Value
ActiveCell.Value = X + "_01"
End Sub
Any ideas on how to increment the string? COuld I convert it to an int and then increment and then convert it back to a string?
[/B]
Excel Workbook | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | DocumentID | Document Date | Sender | Addressees | Other Addressees | ||
2 | H10237RE0001.001.022 | 12/4/2008 | John Doe | Jane Doe | Matt Guy | ||
3 | H10237RE0007.001.032 | 12/5/2008 | Matt Guy | Steve Dude | Zack Boy | ||
Sheet1 |
Excel Workbook | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | DocumentID | Document Date | Sender | Addressees | Other Addressees | ||
2 | H10237RE0001.001.022 | 12/4/2008 | John Doe | Jane Doe | Matt Guy | ||
3 | H10237RE0001.001.022_01 | 12/4/2008 | John Doe | Jane Doe | Matt Guy | ||
4 | H10237RE0007.001.032 | 12/5/2008 | Matt Guy | Steve Dude | Zack Boy | ||
5 | H10237RE0007.001.032_01 | 12/5/2008 | Matt Guy | Steve Dude | Zack Boy | ||
Excel 2007
THe goal is to create a macro that inserts a row and then, copies the Value in column A and increments it by _01. If the row above is already _01, it would become _02
Sheet1 |
Excel 2007
This macro gets me really close except I don't know how to increment the _01 to _02:
Sub InsertRowWithContentsAboveAndAutoIncrementDocNumber()
Dim X As String
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1).EntireRow.Insert Shift:=xlDown
X = ActiveCell.Offset(-1, 0).Value
ActiveCell.Value = X + "_01"
End Sub
Any ideas on how to increment the string? COuld I convert it to an int and then increment and then convert it back to a string?
[/B]