+ Reply to Thread
Results 1 to 12 of 12

Mass insert in large database

Hybrid View

kisboros Mass insert in large database 04-06-2012, 11:11 AM
Richard Buttrey Re: Maybe programming... 04-06-2012, 11:17 AM
jraj1106 Re: Maybe programming... 04-06-2012, 11:31 AM
kisboros Re: Maybe programming... 04-06-2012, 11:34 AM
jraj1106 Re: Mass insert in large... 04-06-2012, 11:37 AM
kisboros Re: Mass insert in large... 04-06-2012, 11:42 AM
kisboros Re: Mass insert in large... 04-06-2012, 11:53 AM
Richard Buttrey Re: Mass insert in large... 04-06-2012, 12:47 PM
kisboros Re: Mass insert in large... 04-06-2012, 01:29 PM
Richard Buttrey Re: Mass insert in large... 04-06-2012, 03:09 PM
kisboros Re: Mass insert in large... 04-06-2012, 04:10 PM
Richard Buttrey Re: Mass insert in large... 04-06-2012, 06:53 PM
  1. #1
    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

    Re: Mass insert in large database

    Hi,

    One way:

    Sub InsertZips()
        Dim x As Long, llastrow As Long
    
        llastrow = Range("A" & Rows.Count).End(xlUp).Row + 1
        Range("K2:K" & llastrow) = "=IF(B2<>B1,""Insert"","""")"
        Range("K:K").Copy: Range("K1").PasteSpecial (xlPasteValues)
        Range("K2").EntireRow.Insert
        Range("I2") = 90058
    
        For x = llastrow + 1 To 4 Step -1
            If Range("K" & x) = "Insert" Then
                Range("K" & x & ":K" & x + 1).EntireRow.Insert
                Range("I" & x & ":I" & x + 1) = 90058
            End If
        Next x
        Range("I" & Rows.Count).End(xlUp).EntireRow.Delete
    
    
    End Sub
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  2. #2
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    128

    Re: Mass insert in large database

    This is what I did: I opened up VBA editor; copied and pasted your code. Then I had to enable macros, and then I clicked on 'Run" and got an error message:
    Compile error: Invalid outside procedure.
    Would it make any difference that it is tab 7 in a workbook? I can see that 'Sheet 7' is highlighted on the sidebar.
    Thank you.

  3. #3
    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

    Re: Mass insert in large database

    Hi,

    The macro should be run with the sheet containing the data is the active sheet. It could be changed to refer to a specific sheet.

    Is your real data EXACTLY the same layout as your example on which the macro is based?

  4. #4
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    128

    Re: Mass insert in large database

    Hi Richard,
    Yes it is. I cut and pasted from the original. Would this forum allow me to send the entire sheet to you to see?
    Thanks,
    Eva

  5. #5
    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

    Re: Mass insert in large database

    Hell Eva,


    You don't need to send the entire workbook if it's very large. Just delete most of the rows but leave a good representative sample and upload.

    Regards

+ 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