LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Insert of Rows

Thanks to Charles' generous offer this is probably not needed, but since
I already wrote it, here goes.

Since inserting multiple rows can be a bit of a headache, I decided to
simply copy the relevant data onto another spreadsheet. Maybe this will
suffice, maybe not.

I assumed that the original data was on "sheet1", starting on row 2
(leaving row 1 for titles).

Sub Do_It()
Dim i As Long, j As Long
Dim k As Long ' counter tracking number of new entries
Dim priname As String, surname As String
dim cost_centre As String, LineManager As String
'assume that original entries are on sheet1, and they
'are being copied to sheet2
i = 2
k = 0
Do
If Sheets("sheet1").Cells(i, 1) = "" Then
'reached the end of the list
Exit Do
End If

priname = Sheets("sheet1").Cells(i, 1)
surname = Sheets("sheet1").Cells(i, 2)
cost_centre = Sheets("sheet1").Cells(i, 4)
LineManager = Sheets("sheet1").Cells(i, 11)

For j = 12 To 26
If Sheets("sheet1").Cells(i, j) < "" Then
k = k + 1 'increment new row counter
Sheets("sheet2").Cells(k, 1) = priname
Sheets("sheet2").Cells(k, 2) = surname
Sheets("sheet2").Cells(k, 4) = cost_centre
Sheets("sheet2").Cells(k, 11) = LineManager
Sheets("sheet2").Cells(k, 27) =
Sheets("sheet1").Cells(1, j)
Sheets("sheet2").Cells(k, 28) =
Sheets("sheet1").Cells(i, j)
End If
Next j

i = i + 1
Loop
End Sub




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
Auto Insert New Rows Eric Excel Discussion (Misc queries) 1 June 14th 07 03:06 PM
how to auto insert rows in Excel TanyaG Excel Discussion (Misc queries) 2 July 4th 05 07:58 PM
Auto Insert Rows of Data?? tojo107 Excel Discussion (Misc queries) 2 May 28th 05 09:28 PM
Auto Insert of Rows Gar3th Excel Worksheet Functions 0 January 6th 05 08:33 PM
Auto Insert Rows Dominique Feteau Excel Programming 2 April 15th 04 09:55 PM


All times are GMT +1. The time now is 05:16 PM.

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"