Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Blank rows

Status
Not open for further replies.

colkas

IS-IT--Management
Aug 26, 2003
39
SE
Hi

We have a spreadsheet linking into our sql databse. We bring out order rows. We sort by order number. If we want to put a blank row after every new order number is there a way to do this?

Thanks
 
Take this as an example:
In the database below, I want to a row to be inserted before every Row where the credit class is "I". Can this be done with the help of a macro? Pls help

CR. CLASS A/c No. Amnt Status
I 1280021514 2431500 active
G 1280035621 3454353 not active
G 3580026521 3454387 active
G 9580025141 9879898 not active
S 1280049936 3621548 not active
D 3580026214 242342 not active
I 8880022221 4334355 active
P 1218005075 34544 not active
Q 1597999218 44414 not active
Q 1977997360 495694 not active
I 2357996503 54724 active
R 2737994645 59879 not active
I 3117993788 65034 not active
R 4564564564 701 active
R 8564564564 75344 not active
The macro would be:
Sub InsertRow()
'
Application.ScreenUpdating = False

Dim FOUND As Range
Dim firstR As Integer

Set FOUND = Cells.Find(What:="I", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)

Let firstR = FOUND.Row + 1

Do
FOUND.Activate
FOUND.EntireRow.Insert

Set FOUND = Cells.Find(What:="I", After:=ActiveCell.Offset(1, 0), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)

Loop Until (FOUND.Row = firstR)

End Sub



 
Hi

I have crested a spreadsheet with a column with a mixture of letters in, however I get an error in the macro. This is my macro so i cannot see where the problem is

Sub insertrow()

Application.ScreenUpdating = False

Dim FOUND As Range
Dim firstR As Integer

SetFOUND = Cells.Find(What:="I", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)

Let firstR = FOUND.Row + 1

Do
FOUND.Activate
FOUND.EntireRow.Insert

Set FOUND = Cells.Find(What:="I", After:=ActiveCell.Offset(1, 0), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)

Loop Until (FOUND.Row = firstR)


End Sub



Also my column would be Order numbers

12345
12345
12346
12347

And I would want the insert to be after a new order number
I asusme this is what should happen with the macro

12345
12345

12346

12347


Any ideas, many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top