LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Macro to insert row.

Steve,

No need to apologize! We just aren't sure of what is happening.

Open a new work book

Copy a few rows ( 4 to 10) from your main workbook into Sheet1 or the new
workbook.
Make sure at least one row in column A has 991CX
Put this code in a module and run it - you should get a message
for each row.

Tell us what happens...

Sub CheckRows()
Dim i As Long
i = 2
Do Until Trim(Cells(i, 1)) = ""
If Cells(i, 1) = "991CX" Then
Msgbox Cells(i, 1).Text & " " Cells(i,1).address
Else
Msgbox Cells(i,1).address & " contains " & cells(i,1).Text & ".end
of text"
End If
i = i + 1
Loop
End Sub

--
steveB

Remove "AYN" from email to respond
"Steve" wrote in message
...
I apologize guys. I am not trying to be a pain. Column A only has Certian
Aircraft tail numbers in it. Column B:G is set up with different sets of
information. I am not sure why. But i can't get this to run.

"STEVE BELL" wrote:

Steve,

Greg's code should work if any cell in column A contains (only) 991CX
If there is more in the cell, than it won't work.

Have you tried testing the code using the F8 key and stepping through it.
Set up a dummy sheet with some cells in column A = 991CX and see what
happens.
(you only need a few rows).

See if you can locate an error or something and get back to us.

Sub InsertRows()
Dim i As Long
i = 2
Do Until Trim(Cells(i, 1)) = ""
If Cells(i, 1) = "991CX" Then
Cells(i, 1).EntireRow.Insert
i = i + 2
Else
i = i + 1
End If
Loop
End Sub

--
steveB

Remove "AYN" from email to respond
"Steve" wrote in message
...
When I ran it it nothing happened.

"Greg Wilson" wrote:

Have you tested mine? Mine does this.

Regards,
Greg

"Steve" wrote:

The value 991CX will not always be in a10. It will always be in
column
A.
Just not always row 10. I am looking for something that will search
col. A
for 991CX, when found, insert a blank row above it. Sorry for the
confusion
guys.

Steve

"Rowan" wrote:

One way is like this:

Sub InsRow()
With Range("A10")
If .Value = "991CX" Then
.EntireRow.Insert
End If
End With
End Sub

otherwise:

Sub InsRow()
If Cells(10, 1).Value = "991CX" Then
Cells(10, 1).EntireRow.Insert
End If
End Sub

Hope this helps
Rowan


Hope this helps
Rowan

"Steve" wrote:

I would like to set up a macro to insert a blank row at specific
spots in a
worksheet. For example, if cell a10 contains 991CX, i would like
to
have a
blank row inserted directly above it. Thanks in advance for any
help you are
able to offer.

Steve








 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to insert a row after every 4th row Amandar097 Excel Discussion (Misc queries) 2 August 20th 09 04:47 AM
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
Macro To Insert Row Jeremy Excel Discussion (Misc queries) 6 March 13th 08 02:52 PM
make a macro to insert a macro mithu Excel Discussion (Misc queries) 6 March 20th 07 06:04 PM
Insert A Row Macro Mark Williams New Users to Excel 2 September 30th 05 07:03 PM


All times are GMT +1. The time now is 12:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"