+ Reply to Thread
Results 1 to 2 of 2

Where Do I Post Code

  1. #1
    Forum Contributor
    Join Date
    03-30-2008
    Posts
    121

    Where Do I Post Code

    I'm new to Excel so please excuse a rookie question.

    I have the piece of code posted below .... however I don't
    know where to place the code.

    I am familiar with Access and TradeStation which require
    coding, but I don't know where this goes in Excel.

    Thanks.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 04-02-2008 at 07:15 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by scotfitz
    I'm new to Excel so please excuse a rookie question.

    I have the piece of code posted below .... however I don't
    know where to place the code.

    I am familiar with Access and TradeStation which require
    coding, but I don't know where this goes in Excel.

    Thanks.

    Sub AddRows()
    Dim x As Integer, y As Integer
    y = Range(Range("A1"), Range("A65536").End(xlUp)).Rows.Count
    Range("E1").Select
    For x = 1 To y
    If ActiveCell.Offset(x - 1, 0) <> ActiveCell.Offset(x, 0) Then
    ActiveCell.Cells(x + 1, 0).EntireRow.Insert
    x = x + 1: y = y + 1
    End If
    Next x

    End Sub
    Hi,

    I thought I recognised the code

    It goes in the Visual Basic Environment (VBE) which sits 'behind' Excel.

    Use the ALT-F11 key to open the VBE
    The top left hand window should be headed up Project Explorer or some such - (I use a Mac and the terminology is sometimes slightly different to a Windows PC)

    This shows all the various objects such as the workbooks that are open in memory, the sheets which each book contains, and any code Modules or User Forms - which you won't have unless any have been created.

    Find your workbook and double click on the 'This Workbook' object. This should open a new large code window on the right. Paste this Procedure in there and you can then close the VBE down - Alt-F11 again.

    Now back in the Excel environment you can go to Tools-->Macro-->Macros, find the Macro name 'AddRows' and oduble click it or press the Run button.

    Hope this helps,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1