#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default insert rows

Dear all


I want to insert rows with first column 2012-2050 if a column is 2011.
I have written this code. Executing it, it will insert a lot of values
after 2011 but then not go to the next column, which it should. any
ideas?

Dim last, limit, i, d, j As Integer
last = 2011
limit = 3000
d = 2050 - last

For i = 1 To limit
If ActiveSheet.Cells(i, 1).Value = last Then
For j = last To 2050
ActiveSheet.Range(Rows(i), Rows(i)).Select
Selection.Insert Shift:=xlDown
Cells(i, 1) = j
Next j
End If
Next i
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default insert rows

Your correct, there is nothing in your code that would cause it to work with
anything but column 1. What do you mean it should go to the next column.
then what happens in the next column? when should it go to the next column?
and if it does go to the next column and do something, what happens after
that? or do you want a Range("B1").Select at the end of the macro?

--
Regards,
Tom Ogilvy

"Dirk" wrote in message
ps.com...
Dear all


I want to insert rows with first column 2012-2050 if a column is 2011.
I have written this code. Executing it, it will insert a lot of values
after 2011 but then not go to the next column, which it should. any
ideas?

Dim last, limit, i, d, j As Integer
last = 2011
limit = 3000
d = 2050 - last

For i = 1 To limit
If ActiveSheet.Cells(i, 1).Value = last Then
For j = last To 2050
ActiveSheet.Range(Rows(i), Rows(i)).Select
Selection.Insert Shift:=xlDown
Cells(i, 1) = j
Next j
End If
Next i
End Sub



Reply
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
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
How do i insert blank rows between data that is thousands of rows paul.eatwell Excel Discussion (Misc queries) 5 April 14th 08 10:49 PM
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
How do I insert blank rows between rows in completed worksheet? bblue1978 Excel Discussion (Misc queries) 1 October 26th 06 07:02 PM
How do i insert of spacer rows between rows in large spreadsheets laurel Excel Discussion (Misc queries) 0 April 24th 06 01:38 PM


All times are GMT +1. The time now is 08:30 AM.

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

About Us

"It's about Microsoft Excel"