Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to insert columns with macro

I've got a spreadsheet that I need to modify. One of the fields says "number
of photos" and I want to take that number, and insert the number of rows I
want right beneath, then continue to the next item in the field and do the
same thing.

In the other columns, I want to copy the data that's there to the new
row(s).

I can't find a command to automatically insert a row, though.

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default How to insert columns with macro

This will insert the rows for you.

Sub InsertRows()
Dim LastRow As Long
Dim i As Long
Application.ScreenUpdating = False
LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 1 Step -1
If IsNumeric(Range("A" & i)) Then
Range("A" & i).Offset(1, 0).Resize(Range("A" & i)).EntireRow.Insert
End If
Next 'i
Application.ScreenUpdating = True
End Sub

Regards

Trevor


"THE GAME" wrote in message
...
I've got a spreadsheet that I need to modify. One of the fields says

"number
of photos" and I want to take that number, and insert the number of rows I
want right beneath, then continue to the next item in the field and do the
same thing.

In the other columns, I want to copy the data that's there to the new
row(s).

I can't find a command to automatically insert a row, though.

Thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to insert columns with macro

Numrows = 10
ActiveCell.Resize(numRows,1).EntireRow.Insert


--
Regards,
Tom Ogilvy


"THE GAME" wrote in message
...
I've got a spreadsheet that I need to modify. One of the fields says

"number
of photos" and I want to take that number, and insert the number of rows I
want right beneath, then continue to the next item in the field and do the
same thing.

In the other columns, I want to copy the data that's there to the new
row(s).

I can't find a command to automatically insert a row, though.

Thanks in advance.




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
Macro to insert and move columns andrea Excel Discussion (Misc queries) 3 October 8th 08 06:55 AM
can no longer insert new columns & unhide hidden columns em2 Excel Worksheet Functions 1 July 19th 07 03:18 AM
unable to insert columns in excel, insert- columns (disabled) iam_leearner Excel Discussion (Misc queries) 1 August 13th 06 02:26 PM
insert columns macro is putting 2 columns instead of 1 AGH Excel Worksheet Functions 2 February 27th 06 02:36 PM
Macro to insert page breaks when values in 1 or more columns changes Michael G Excel Programming 5 October 3rd 03 01:48 AM


All times are GMT +1. The time now is 04:19 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"