I am researching my Great Great Grandfathers time during the Civil War. What started to be a simple Excel file has grown to a large file, 25000+ rows. Not what I planned for but the further I got in the research the more I expanded to included all members of his units. I am new to VBA and have am trying to learn the basics to complete this document. If this request is not allowed please let me know.
Flow
Search Column D for Cell "Rank:"
When found, insert row below this Cell
Also, insert text "Age:" in column D in new row
Insert row below Cell with "Age"
insert "Residence:" in column D of this row
Loop through Range of Spreadsheet
Repeat
Until end of document
End
This is a code I found online, to enter one line but it does not work as expected. Any help would be greatly appreciated.
Sub Insert_Row_Below_Blank()
Dim i As Range
Dim cell As Range
Set i = Range("D1:D25391")
For Each cell In i.Cells
If cell.Value = "Rank:" Then
cell.Offset(1).EntireRow.Insert
End If
Next
End Sub
Excel 2016 (Windows) 32 bit
<tbody>
</tbody>
Flow
Search Column D for Cell "Rank:"
When found, insert row below this Cell
Also, insert text "Age:" in column D in new row
Insert row below Cell with "Age"
insert "Residence:" in column D of this row
Loop through Range of Spreadsheet
Repeat
Until end of document
End
This is a code I found online, to enter one line but it does not work as expected. Any help would be greatly appreciated.
Sub Insert_Row_Below_Blank()
Dim i As Range
Dim cell As Range
Set i = Range("D1:D25391")
For Each cell In i.Cells
If cell.Value = "Rank:" Then
cell.Offset(1).EntireRow.Insert
End If
Next
End Sub
Excel 2016 (Windows) 32 bit
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Document ID | Person_ID | Name | Details | Notes |
2 | xxxxxx | ||||
3 | xxxxxx | Service: | |||
4 | xxxxxx | Location: | |||
5 | xxxxxx | Regiment: | |||
6 | xxxxxx | Function: | |||
7 | xxxxxx | Company: | |||
8 | xxxxxx | Rank: | |||
9 | xxxxxx | Enrolled: | |||
10 | xxxxxx | Date: | |||
11 | xxxxxx | Enlisted: | |||
12 | xxxxxx | Date: | |||
13 | xxxxxx | Detail: | |||
14 | xxxxxx | Captured: | |||
15 | xxxxxx | Prisoner: | |||
16 | xxxxxx | Died: | |||
17 | xxxxxx | Cause: | |||
18 | xxxxxx | Buried: | |||
19 | mmmm | ||||
20 | mmmm | Service: | |||
21 | mmmm | Location: | |||
22 | mmmm | Regiment: | |||
23 | mmmm | Function: | |||
24 | mmmm | Company: | |||
25 | mmmm | Rank: | |||
26 | mmmm | Enrolled: | |||
27 | mmmm | Date: | |||
28 | mmmm | Enlisted: | |||
29 | mmmm | Date: | |||
30 | mmmm | Detail: | |||
31 | mmmm | Captured: | |||
32 | mmmm | Prisoner: | |||
33 | mmmm | Exchanged: | |||
34 | mmmm | Location: | |||
35 | mmmm | Battle: | |||
36 | mmmm | Date: | |||
37 | mmmm | Detail: | |||
38 | mmmm | Location: | |||
39 | mmmm | Date: | |||
40 | mmmm | Captured: | |||
41 | mmmm | Forwarded: | |||
42 | mmmm | Date: | |||
43 | mmmm | Date: | |||
44 | mmmm | Location | |||
45 | mmmm | Died: | |||
46 | mmmm | Cause: | |||
47 | mmmm | Buried: |
<tbody>
</tbody>
Sheet1