Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:48:22+00:00 2026-06-16T16:48:22+00:00

I do not have much experience with writing macros, and therefore need the help

  • 0

I do not have much experience with writing macros, and therefore need the help of this community for the following issue encountered:

My macro copies a range of values entered in a vertical range in one worksheet and then pastes the values horizontally (transpose) in another worksheet. It would in theory paste the values from the first sheet to first row of the second worksheet which does not have content. Since the first five rows have contents, it thus pastes the values to the sixth row.
The problem I have with the running of the macro is that I feel like it is too slow and I would therefore like it to run faster.

I have the same macro doing the same thing but that instead pastes the values to another worksheet to the first row, and it runs perfect.

My best guess is therefore that the second macro is running slow because it has to start pasting on the sixth row and there may be some contents on the first 5 rows that take a lot of time for the macro to go through (there a lot of cell references to other workbooks) to determine where the next row for pasting should be. That is my best guess though and since I hardly know anything about macros, I cannot say for sure what the problem is.

I hereby provide you with the code of my macro and sincerely hope that somebody can tell me what is making my macro slow and provide me with a solution as to how to make it run faster. I am thinking that a solution might potentially be that the macro should not consider the first five rows of data and start pasting immediately on row 6 for the first entry. Then on row 7 the next time, and etc. This might be a solution but I do not know how to write the code in a way that it would do that.

Thank you for taking time and helping me to find a solution, here is the code:

Sub Macro1()
Application.ScreenUpdating = False

    Dim historyWks As Worksheet
    Dim inputWks As Worksheet

    Dim nextRow As Long
    Dim oCol As Long

    Dim myCopy As Range
    Dim myTest As Range

    Dim lRsp As Long

    Set inputWks = wksPartsDataEntry
    Set historyWks = Sheet11

      'cells to copy from Input sheet - some contain formulas
      Set myCopy = inputWks.Range("OrderEntry2")

      With historyWks
          nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
      End With

      With inputWks
          Set myTest = myCopy.Offset(0, 2)

          If Application.Count(myTest) > 0 Then
              MsgBox "Please fill in all the cells!"
              Exit Sub
          End If
      End With

      With historyWks
          With .Cells(nextRow, "A")
              .Value = Now
              .NumberFormat = "mm/dd/yyyy hh:mm:ss"
          End With
          .Cells(nextRow, "B").Value = Application.UserName
          oCol = 3
          myCopy.Copy
          .Cells(nextRow, 3).PasteSpecial Paste:=xlPasteValues, Transpose:=True
          Application.CutCopyMode = False
      End With

      'clear input cells that contain constants
      With inputWks
        On Error Resume Next
           With myCopy.Cells.SpecialCells(xlCellTypeConstants)
                .ClearContents
                Application.GoTo .Cells(1) ', Scroll:=True
           End With
        On Error GoTo 0
      End With

Application.ScreenUpdating = True
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:48:24+00:00Added an answer on June 16, 2026 at 4:48 pm

    Just reiterating what has already been said:

    Option Explicit
    
    Sub Macro1()
    
    'turn off as much background processes as possible
    With Excel.Application
            .ScreenUpdating = False
            .Calculation = Excel.xlCalculationManual
            .EnableEvents = False
    End With
    
        Dim historyWks As Excel.Worksheet
        Dim inputWks As Excel.Worksheet
    
        Dim nextRow As Long
        Dim oCol As Long
    
        Dim myCopy As Excel.Range
        Dim myTest As Excel.Range
    
        Dim lRsp As Long
    
        Set inputWks = wksPartsDataEntry
        Set historyWks = Sheet11
    
          'cells to copy from Input sheet - some contain formulas
          Set myCopy = inputWks.Range("OrderEntry2")
    
          With historyWks
              nextRow = .Cells(.Rows.Count, 1).End(Excel.xlUp).Offset(1, 0).Row
          End With
    
          With inputWks
              Set myTest = myCopy.Offset(0, 2)
    
              If Excel.Application.Count(myTest) > 0 Then
                  MsgBox "Please fill in all the cells!"
                  GoTo QuickExit
              End If
          End With
    
          With historyWks
              With .Cells(nextRow, 1)
                  .Value = Now
                  .NumberFormat = "mm/dd/yyyy hh:mm:ss"
              End With
              .Cells(nextRow, 2).Value = Excel.Application.UserName
              oCol = 3
              myCopy.Copy
              .Cells(nextRow, 3).PasteSpecial Paste:=Excel.xlPasteValues, Transpose:=True
              Excel.Application.CutCopyMode = False
          End With
    
          'clear input cells that contain constants
          With inputWks
            On Error Resume Next
               With myCopy.Cells.SpecialCells(Excel.xlCellTypeConstants)
                    .ClearContents
                    Excel.Application.Goto .Cells(1) ', Scroll:=True
               End With
            On Error GoTo 0
          End With
    
        Calculate
    
    QuickExit
    
    With Excel.Application
            .ScreenUpdating = True
            .Calculation = Excel.xlAutomatic
            .EnableEvents = True
    End With
    
    End Sub
    

    I’d step through the macro line-by-line to try to locate which line is slow.

    Another alternative – although not sure if it’ll speed things up – is to avoid the clipboard and lose the copy/paste so you’d apply a method like the following to move the data:

    Option Explicit
    
    Sub WithoutPastespecial()
    
    'WORKING EXAMPLE
    
    Dim firstRange As Range
    Dim secondRange As Range
    
    Set firstRange = ThisWorkbook.Worksheets("Cut Sheet").Range("S4:S2000")
    With ThisWorkbook.Worksheets("Cutsheets")
        Set secondRange = .Range("A" & .Rows.Count).End(Excel.xlUp).Offset(1)
    End With
    
    With firstRange
          Set secondRange = secondRange.Resize(.Rows.Count, .Columns.Count)
    End With
    secondRange.Value = firstRange.Value
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not have much experience on this but I want to position two
I'm currently extending a Site and do not have much experience with symfony. Currently
I have 4 years experience on DotNet, not much. I now learned developing for
I have a fair amount of JSP and JSF experience. Not so much with
I've been working at this for two days and have not had much luck.
I have a much simpler set of requirements and do not need much of
I have not worked with parameters in ADO.Net very much. I'm writing a custom
Ugh - not sure why I'm having so much trouble with this. Writing a
I live in Australia and have not dealt much with imperial length measurements. How
I'm trying to define a new type and have not had much luck finding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.