Macro that inserts lines

I have this macro that inserts a line if the value in D changes and copy the 
value in D to A. I want this macro to only start looking in D14 or from row 
14. 

tx for all the help


Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = lastrow - 1 To 2 Step -1
    If Cells(row_index, "D").Value <> _
      Cells(row_index + 1, "D").Value Then
        Cells(row_index + 1, "D").EntireRow.Insert _
          (xlShiftDown)
    Cells(row_index + 1, 1).Value = Cells(row_index + 2, 4).Value
    End If
Next
End Sub
0
Esrei1 (23)
5/9/2005 12:36:04 PM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
986 Views

Similar Articles

[PageSpeed] 7

Is it not working then? If so, how?

-- 
 HTH

Bob Phillips

"Esrei" <Esrei@discussions.microsoft.com> wrote in message
news:A16B2238-82FE-4FA3-836B-5ECB7B316CD5@microsoft.com...
> I have this macro that inserts a line if the value in D changes and copy
the
> value in D to A. I want this macro to only start looking in D14 or from
row
> 14.
>
> tx for all the help
>
>
> Dim row_index As Long
> Application.ScreenUpdating = False
> lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
> For row_index = lastrow - 1 To 2 Step -1
>     If Cells(row_index, "D").Value <> _
>       Cells(row_index + 1, "D").Value Then
>         Cells(row_index + 1, "D").EntireRow.Insert _
>           (xlShiftDown)
>     Cells(row_index + 1, 1).Value = Cells(row_index + 2, 4).Value
>     End If
> Next
> End Sub


0
phillips1 (803)
5/9/2005 12:50:22 PM
Reply:

Similar Artilces:

The item number is missing in line '1'
Hi, Upon using Integration manager 9.0 using the Inventory transaction (adjustment), we are encountering the error "The item number is missing in line '1' ". When I run the integration in my computer there is no error, but upon running it using other computers, this error appears. I'm using the same text files and the same mapping of fields. We are using GP 9.0. Thanks, Mel ...

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

when inserting a chart excel is saying i cannot add any new fonts
When I attempt to insert a chart i am getting a message which says,"no new fonts may be added to this workbook". I am adding it to a billing process and I did the first 100 or so before it began this doing this, I am not adding any new fonts but I am getting this message, any suggestions on what is the cause so I can overcome it? I've described the problem and fix here: Error: "No more new fonts may be applied in this workbook" http://peltiertech.com/Excel/Charts/FixFonts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltier...

inserting a picture
hi I need your expertise regarding inserting a picture in word 2007. When I hit the office button and go to open then my pictures, pick the picture i want and then click open. After that it brings up the convert file dialogue box and i cant bring up the picture. Can you help me with this problem? Thank you , Joe. Hi, I am not that sure why that problem is happening but i believe that it is having problem importing pictures that are in another format. I want to know a few things: Where did you get the picture? What is its file extension? Make sure that your pictu...

Shade under a line
I have scatterplots with date/time along the X axis, and data on the Y axis. I'd like to add shading from sunrise to sunset. I can create a line on the scatterplot that is 0 during the day and a value greater than the max Y value at night, but would like to be able to shade under this line to more easily visualize when it's dark. I also tried creating a bar graph in the background on a second X axis, thinking I could have small categories with date and light/dark data, but the time axis cannot do increments smaller than days, so that hasn't worked. Any suggestions? I ha...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Let me use the Line Color icon on charts
It would speed up a lot of my work if I could use the Line Color icon on Excel charts, the same way I am able to use the Fill Color and Font Color icons. However, when I highlight any chart object, like the Plot Area, Chart Area, or a Series, the Line Color icon is disabled. -- Stuart Bratesman, Jr., MPP Muskie School of Public Service Univ. of Southern Maine Portland, Maine ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If ...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

Graphics Insert into Publisher Doc.
When ever I insert a graphic into my publisher docs. they appear as a series of dashes around the perimeter of the graphic & across the diagonals of the graphic not the actual graphic I am trying to work with. Can anyone advise of a fix as this is driving me insane. Regards, Longa Do you have detailed display enabled? View, pictures, detailed display... Otherwise you may need to update your graphics/video driver. Slide the acceleration down on your adapter, control panel, display folder, settings tab, advanced button, troubleshoot tab. If your images appear, then go to the manufacturer...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

Cannot insert new rows
I am running excel 2007 and I have 23 worksheets in a workbook. I have no links or hidden rows or colums. My biggest sheet is A1: AW8096. I use VB macros to add lines and move data from one set of workbooks to this one. I have built several sheets using this proceedure. All of a sudden I get the error "Cannot shift objects off sheet" when I run a routine I have 50,000 times. I have checked to make sure there are no hidden comments, row or columns. I have deleted most of the worksheets and I still get the error. I have made copies of the workbook and used different file ...

Multiple lines in datasheet view
Hi all Is it possible to have multiple lines in the header of a Form in Datasheet view? We have a Form that has long field names e.g Date invoice completed. In datasheet view this consumes a large amount of screen space, therefore if it could be shown on 2 or more lines would be good as follows: Date Invoice completed Similar to text wrapping in Excel. Thanks in advance Nope, sorry that functionality doesn't currently exist. I agree it would be a good one to add (Microsoft - take note :-) ) -- Bob Larson Access World Forums Super Moderator Utter Access VIP Tutorials at http://www...

SQL Statement Insert Into
I need to append data from one table1 to table2 using the field in table3 as the criteria. This field in question is 'account number'. How can I write a sql statement to accomplish this? Troy, What binds the tables? In other words, how are they related to each other? Unless the account number is the same for every entity in Table2? -- Gina Whipp 2010 Microsoft MVP (Access) "I feel I have been denied critical, need to know, information!" - Tremors II http://www.regina-whipp.com/index_files/TipList.htm "Troy" <Troy@discussions.mic...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

Trend Line constants as Excel Cell Values
I want to put the constants of a 2 degree polynomial trend line into Excel Cells. Are there formula's to do this? Equation is Y = Ax(2) + Bx + C. I want the value of A,B and C in seperate cells. Can anyone suggest how this can be done? Thanks -- Ken Hi Ken, Supposing your x-range is in A2:A10, and y-range in B2:B10, select a 3-column x 1-row area and enter the following formula and confirm with CTRL-SHIFT-ENTER. =LINEST(B2:B10,A2:A10^{0,1,2},0,) Regards, B. R. Ramachandran "Ken" wrote: > I want to put the constants of a 2 degree polynomial trend line into Excel &g...

insert category Id into Items table
Can some please help me how to insert the ID from Category and Department tables into the Items table. I have the does some one have the correct SQL for this Thank you jm can u explain it further? "jm" wrote: > Can some please help me how to insert the ID from Category and Department > tables into the Items table. I have the does some one have the correct SQL > for this > Thank you > jm ...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...

Chart Label wraps on the same line. "Wavelenght [nm]" appears as.
Chart Label wraps on the same line. example "Wavelenght [nm]" appears as "}Wavelenght [nm" in general the chart labels are not what i typed. Send me a copy of the file (personal mail not to newsgroup) What version of Excel are you using? -- Bernard Liengme www.stfx.ca/people/bliengme remove CAPS in email address "rog" <rog@discussions.microsoft.com> wrote in message news:E9369578-AA4B-480B-93A2-14D91B8AC1F8@microsoft.com... > Chart Label wraps on the same line. example "Wavelenght [nm]" appears as > "}Wavelenght [nm" >...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...