+ Reply to Thread
Results 1 to 4 of 4

Macro needed for a new row and a new column.

Hybrid View

charles.2345 Macro needed for a new row... 11-06-2008, 01:53 AM
StephenR This is a little confusing.... 11-06-2008, 02:17 AM
Paul Not sure if this is what... 11-06-2008, 02:28 AM
charles.2345 Thanks all - Problem solved 11-06-2008, 04:07 PM
  1. #1
    Registered User
    Join Date
    05-26-2008
    Posts
    28

    Macro needed for a new row and a new column.

    Hello experts,

    I was wondering if we can program a macro to:
    1) Insert a row above the current cell selected, and then filling a single space in the first 24 cells of the row.
    2) Insert a column above the current cell selected, and then filling a single space in the first 100 cells of the column.

    If you give me the code for 1 and 2, I will probably be able to make the third macro which does both of the above.

    Thanks.
    Charles.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    This is a little confusing.
    filling a single space in the first 24 cells of the row
    What does this mean? Filling with what?
    Insert a column above the current cell selected
    Columns can't be above - do you mean to the left or right?

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Not sure if this is what you're after, but making some assumptions it might work. This code inserts a row above the current cell then inserts a space character into columns A:X of that new row. It then inserts a column to the left of the active cell and inserts a space character in the first 100 cells in that column.
    Sub insertRC()
        ActiveCell.EntireRow.Insert
        Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 24)).Value = " "
        ActiveCell.EntireColumn.Insert
        Range(Cells(1, ActiveCell.Column), Cells(100, ActiveCell.Column)).Value = " "
    End Sub
    If that's not what you're looking for you will need to provide more details.

  4. #4
    Registered User
    Join Date
    05-26-2008
    Posts
    28

    Thanks all - Problem solved

    Thanks PjoAcquin. It worked. But i want to ask this:

    Why does running this macro twice give error?

     
    Sub fill_final()
    '
    ' fill_final Macro
    ' Macro recorded 11/3/2008 by ***.
    '
    ' Keyboard Shortcut: Ctrl+Shift+E
    '
    Range("A1:V100").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    ' error in above line
    Selection.FormulaR1C1 = " "
    End Sub
    Is it because there is no blank cell to select?
    How can I modify the code so that I don't get an error if I repeat run the macro.

    Best,
    Charles.
    Last edited by VBA Noob; 11-06-2008 at 04:08 PM. Reason: Added code tags as per forum rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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