+ Reply to Thread
Results 1 to 16 of 16

Insert Values only

Hybrid View

stockgoblin42 Insert Values only 05-14-2013, 03:22 PM
NeedForExcel Re: Insert Values only 05-14-2013, 03:44 PM
stockgoblin42 Re: Insert Values only 05-14-2013, 05:30 PM
NeedForExcel Re: Insert Values only 05-14-2013, 11:13 PM
HaHoBe Re: Insert Values only 05-15-2013, 12:45 AM
NeedForExcel Re: Insert Values only 05-15-2013, 03:08 PM
Leith Ross Re: Insert Values only 05-15-2013, 03:30 PM
HaHoBe Re: Insert Values only 05-15-2013, 03:42 PM
Leith Ross Re: Insert Values only 05-15-2013, 03:51 PM
stockgoblin42 Re: Insert Values only 05-17-2013, 10:52 AM
HaHoBe Re: Insert Values only 05-17-2013, 01:08 PM
stockgoblin42 Re: Insert Values only 05-17-2013, 01:19 PM
  1. #1
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Insert Values only

    Hi,

    Currently I'm using:

    Sheets("Analyzer").Select
              Range("A2:M6").Select
              Selection.copy
              Sheets("Results").Select
              Range("A2").Select
              Selection.Insert Shift:=xlDown
    Is there a faster way to do this that only inserts the values? I do require an insert, not just a paste.
    Last edited by stockgoblin42; 05-14-2013 at 03:27 PM.
    live logic & long prosper

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Insert Values only

    With Faster, do you mean a faster Macro or a Smaller Macro?

    Coz as far as those above codes are concerned, its fast enough..
    Cheers!
    Deep Dave

  3. #3
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Insert Values only

    I mean faster, plain and simple because it's in a loop that does it hundreds of times.

    I recently learned the faster way of copy and paste without the Selecting and Activating and I was wondering if Insert was like that too.

    Also, I want to insert just the values as the above does the formulas too and I don't want them.

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Insert Values only

    As far as my knowledge is concerned, there is no faster way. The best you can do is turn Screenupdating to false.

    This would increase your macro speed.

    Thank You,

    Deep

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Insert Values only

    Hi, stockgoblin42,

    maybe
    Sheets("Analyzer").Range("A2:M6").Copy
    Sheets("Results").Range("A2").Insert Shift:=xlDown
    where no change of the active sheet is done.

    @Deep:
    Any Select or Activate will slow any action down increasingly. ScreenUpdating may speed things up but the slowliness comes from other parts which by using them properly will increase speed without turning Updating off.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Insert Values only

    Noted!!

    Thank You,

    Deep

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Insert Values only

    Hello stockgoblin42,

    If you don't need to copy over the cell formatting then the quickest way is by direct assignment...
    Sheets("Analyzer").Range("A2:M6").Value =  Sheets("Results").Range("A2").Value
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Insert Values only

    Hi, Leith,

    and that sniplet will insert the cells into the sheet where the values are copied like
              Range("A2").Select
              Selection.Insert Shift:=xlDown
    from the opening post show? I dare to doubt.

    CIao,
    Holger

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Insert Values only

    Hello Holger,

    I forgot to mention, for this method to work the ranges must have the same number of rows and columns. The example below will overwrite any previous information on the second sheet.
    Sheets("Analyzer").Range("A2:M6").Value =  Sheets("Results").Range("A2":M6).Value
    If the values from the first sheet are to be appended to the existing data then the code would be this...
    Sheets("Analyzer").Range("A2:M6").Value =  Sheets("Results").Cells(Rows.Count, "A").End(xlUp)Offset(1, 0).Resize(1, 13).Value

  10. #10
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Insert Values only

    Hi,


    I'm getting an Expected End of Statement with the Offset highlighted when I replace:

    Sheets("Analyzer").Select
              Range("A2:M6").Select
              Selection.copy
              Sheets("Results").Select
              Range("A2").Select
              Selection.Insert Shift:=xlDown
    with your suggestion of:

    Sheets("Analyzer").Range("A2:M6").Value =  Sheets("Results").Cells(Rows.Count, "A").End(xlUp)Offset(1, 0).Resize(1, 13).Value


    Any ideas Why?
    Last edited by stockgoblin42; 05-17-2013 at 10:55 AM.

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Insert Values only

    Hi, stockgoblin42,

    I bet you can figure it out by youurself if you count out how many rows there are from 2 to 6 - definitely not 1.

    And as mentioned the code would always overwrite the same area.
    Sheets("Results").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Resize(5, 13).Value = _
        Sheets("Analyzer").Range("A2").Resize(5, 13).Value
    Ciao,
    Holger

  12. #12
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Insert Values only

    Oh, I'm looking for an insert, definately not an overwrite

    something to replace:

    Sheets("Analyzer").Select
              Range("A2:M6").Select
              Selection.copy
              Sheets("Results").Select
              Range("A2").Select
              Selection.Insert Shift:=xlDown
    but faster, without the selecting

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Insert Values only

    Hi, stockgoblin42,

    maybe have a look at the code provided in my first post in this thread.

    Ciao,
    Holger

+ 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