|
-
Jun 2nd, 2005, 09:21 AM
#1
Thread Starter
Fanatic Member
Insert Row Excel
I need to write a macro which will insert a new row into certain locations within my excel worksheet.
i.e. if the data in column A's changes i need to insert a new row...
For example, the first 50 rows in my column A have got the word "Boston". Then Row 51 changes to "New York". When the word changes to new york i need to add on blank row.
is this possible?
-
Jun 2nd, 2005, 10:12 AM
#2
Re: Insert Row Excel
Yes.
Loop from the top to the bottom of your records (how you get the bottom row is up to you but perhaps : sht.cells(65530,1).End(xlUp).Row )
Hold the current value in a variable.
If you are on the first/second row (depending on titles etc) then do not add a line otherwise;
if the current cell is different than the held value
- store the current cells value
- insert a row
- The bottom row (value) should be increased by one
- the current cell should move down (increment) by one
If the cell value is the same then move on to the next one
post up once you've tried some code (if it doesn't work)
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|