+ Reply to Thread
Results 1 to 9 of 9

Insert limited cells when you insert a row

Hybrid View

  1. #1
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    35

    Insert limited cells when you insert a row

    Hi hope you can help, i have a sheet with data validation in column A. when i want to add a row to add extra data if i insert row it does the whole row, but is there a way to limit the insert to only say columns A to AG cells as i have information in columns AH that i don't want to have cells inserted. this will eventually be put into a macro to repeat this in other tabs in the same workbook.
    Thanks

  2. #2
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    Re: Insert limited cells when you insert a row

    Can you attach a copy?

  3. #3
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    35

    Re: Insert limited cells when you insert a row

    Excel.JPG
    As you can see the Task description and the Frequency columns have the data validation so if i select say row 10 to add a space to add more data in the 2 data validation columns in the first section on the left i don't want the row to add cells past the column with the day 31, and that would also apply to the second set of data on the right hand side of the page

  4. #4
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    Re: Insert limited cells when you insert a row

    Without seeing your workbook you could maybe use something like this in your Sheet Module. Right Click the sheet name you want this to work on and click 'View Code' then paste the code there.
    Then double click in a cell to insert a row below. You can change the values in the code as needed for your sheet.
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim i, x As Integer, sh As Worksheet, wb As Workbook
    Set wb = ThisWorkbook
    Set sh = wb.Worksheets(ActiveSheet.Name)
    i = Target.Column
    x = Target.Row
    
    'Change These Values As Needed For Your Sheet Ranges
    
    'Columns 1 - 33 (A - AG)
    If i >= 1 And i <= 33 Then
    sh.Range(Cells(x, 1), Cells(x, 33)).Copy
    sh.Range(Cells(x, 1), Cells(x, 33)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End If
    'Columns 34 - 66 (AH - BN)
    If i >= 34 And i <= 66 Then
    sh.Range(Cells(x, 34), Cells(x, 66)).Copy
    sh.Range(Cells(x, 34), Cells(x, 66)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove 'Range 2
    End If
    
    Application.Goto Target
    Application.CutCopyMode = False
    End Sub

  5. #5
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    35

    Re: Insert limited cells when you insert a row

    https://www.excelforum.com/attachmen...1&d=1546719431

    I think i have attached the spreadsheet, if you can have a look.
    Thanks
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    Re: Insert limited cells when you insert a row

    Did you try the code I posted? If so, does that work for you? If not, can you give me a detailed explanation of what you would like to be able to do with this workbook?

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,566

    Re: Insert limited cells when you insert a row

    If I interpret your Post #1 right, this should do.
    Range("A10:AG10").Insert Shift:=xlDown
    If there is more involved then you'll have to use unit285's code that copies down formats

  8. #8
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    35

    Re: Insert limited cells when you insert a row

    Thanks for feedback unit285 and jolivanes, i ended up using unit285's coding and then created a macro to transfer the updated sheet to the other 11 tabs and its works fine, much appreciated the quick responses

  9. #9
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    Re: Insert limited cells when you insert a row

    Happy it worked for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vba that moves cells with text, (up and to left, insert row/ insert copied cell)
    By sergi117 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2018, 03:12 PM
  2. [SOLVED] Enable the Insert icon in Developer tab > Controls > Insert in Excel 2010
    By pedapudipradeep in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-03-2014, 12:41 PM
  3. Replies: 6
    Last Post: 10-02-2014, 06:31 AM
  4. Replies: 3
    Last Post: 10-25-2012, 07:10 AM
  5. Help - Insert method of Range class failed - Selection.Insert Shift:=xlToRight
    By sandy@excelforum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2012, 11:14 AM
  6. Limited column range, can't insert column
    By kanne in forum Excel General
    Replies: 1
    Last Post: 01-04-2011, 06:08 AM

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