ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro To Find Data And Insert Row (https://www.excelbanter.com/excel-programming/353386-macro-find-data-insert-row.html)

quinla01

Macro To Find Data And Insert Row
 

*Hi guys, any help on this one would be great*.

I've got a problem that's causing me a headache. i have a document with
1 column and 4000 rows (its an export from active directory).

I need to do a search cell by cell (so A1 - A4000) for any cells that
contain the text "changeType". When a cell is found, i need excel to
insert a new row above the current cell and insert the text "modify"
into the new row (in the first column).

eg.

x
x
x
changeType
x
x

Becomes:

x
x
x
Modify
ChangeType
x
x

I dont use excel much so i'm pretty novice.

Thanks for any help you can offer

Andy


--
quinla01
------------------------------------------------------------------------
quinla01's Profile: http://www.excelforum.com/member.php...o&userid=31583
View this thread: http://www.excelforum.com/showthread...hreadid=512741


Mr. Know Nothing

Macro To Find Data And Insert Row
 
Quinla01,
Use the line Selection.EntireRow.Insert to insert a new row after you
have found where you wish to add it.

MR. KN

"quinla01" wrote:


*Hi guys, any help on this one would be great*.

I've got a problem that's causing me a headache. i have a document with
1 column and 4000 rows (its an export from active directory).

I need to do a search cell by cell (so A1 - A4000) for any cells that
contain the text "changeType". When a cell is found, i need excel to
insert a new row above the current cell and insert the text "modify"
into the new row (in the first column).

eg.

x
x
x
changeType
x
x

Becomes:

x
x
x
Modify
ChangeType
x
x

I dont use excel much so i'm pretty novice.

Thanks for any help you can offer

Andy


--
quinla01
------------------------------------------------------------------------
quinla01's Profile: http://www.excelforum.com/member.php...o&userid=31583
View this thread: http://www.excelforum.com/showthread...hreadid=512741



Tom Ogilvy

Macro To Find Data And Insert Row
 
Sub EFG()
Dim i As Long
i = 1
Do While Cells(i, 1) < ""
If InStr(1, Cells(i, 1), "changetype", _
vbTextCompare) Then
Rows(i).Insert
Cells(i, 1) = "Modify"
i = i + 2
Else
i = i + 1
End If
Loop

End Sub

--
Regards,
Tom Ogilvy


"quinla01" wrote in
message ...

*Hi guys, any help on this one would be great*.

I've got a problem that's causing me a headache. i have a document with
1 column and 4000 rows (its an export from active directory).

I need to do a search cell by cell (so A1 - A4000) for any cells that
contain the text "changeType". When a cell is found, i need excel to
insert a new row above the current cell and insert the text "modify"
into the new row (in the first column).

eg.

x
x
x
changeType
x
x

Becomes:

x
x
x
Modify
ChangeType
x
x

I dont use excel much so i'm pretty novice.

Thanks for any help you can offer

Andy


--
quinla01
------------------------------------------------------------------------
quinla01's Profile:

http://www.excelforum.com/member.php...o&userid=31583
View this thread: http://www.excelforum.com/showthread...hreadid=512741





All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com