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

  • SEARCH
  • Home
  • 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 6075671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:31:13+00:00 2026-05-23T10:31:13+00:00

I am trying to create a relatively simple copy and paste procedure. I have

  • 0

I am trying to create a relatively simple copy and paste procedure. I have certain cell addresses stored in an array (Results1()) and I am trying to extrapolate the row which it is in to copy an entire row of data into another Excel sheet. I have the following so far and currently I am getting an object required error when I try to define what my ‘NextRow’ is. Any advice or feedback would be greatly appreciated!

For i1 = LBound(Results1) To UBound(Results1)
    Set NextRow = Worksheets("searchresult").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Range(Results(i1)).EntireRow.Copy NextRow
Next i1

Editted code

    For i1 = LBound(Results1) To UBound(Results1)
        Worksheets("properties").Select
        Set p1results = Range(Results1(i1))
        p1results.EntireRow.Copy
            With Worksheets("SearchResult").Select
                NextRow = Range("D65536").End(xlUp).Row + 1
                Cells(NextRow, 1).Select
                ActiveSheet.Paste
            End With
    Next i1

Update: In actuality my data ranges only range from columns D:P so when I count rows I count from column D (4) because columns A-C are empty ranges. Would this affect the way it is pasting my data?

       On Error Resume Next
   For i1 = LBound(Results1) To UBound(Results1)
        Set NextRow = shSearchResult.Cells(shSearchResult.Rows.Count, 4).End(xlUp).Offset(1, 0)
        shProperties.Range(Results1(i1)).EntireRow.Copy NextRow
        If Err.Number <> 0 Then
            Err.Clear
            MsgBox "Bad address" & Results1(i1)
        End If
    Next i1
  • 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-05-23T10:31:14+00:00Added an answer on May 23, 2026 at 10:31 am

    A few potential causes here:

    Your for loop references Results1 but your copy references Results (typo in question? or route cause?)

    In your Set NextRow = line references .Cells(Rows.Count, unqualified, Rows refers to the active sheet not "searchresult" sheet. Probably not what you intended, but also will meke no difference in this case.

    Likewise Range(Results(i1)) refers to the active sheet, may be ok – depends on the wider context of your application

    I suspect that your imediate problem is that NextRow has not been DIM‘d. Try adding

    Dim NextRow as Range to your Sub

    In general it is good practice to use Option Explicit (first line in your module). This forces explicit declaration of all variable.

    EDIT

    based on your edit a "Method 'Range' of object '_Global' failed" error may be caused by an invalid adress string

    Your first code was actually better than your second. Here’s a refactor version

    Sub zxx()
        Dim Results1(0 To 1) As Variant
        Dim i1 As Long
        Dim NextRow As Range
        Dim shProperties As Worksheet
        Dim shSearchResults As Worksheet
    
    
        '  other code ...
    
        Set shSearchResults = ActiveWorkbook.Worksheets("searchresult")
        Set shProperties = ActiveWorkbook.Worksheets("properties")
    
        On Error Resume Next
        For i1 = LBound(Results1) To UBound(Results1)
            Set NextRow = shSearchResults.Cells(shSearchResults.Rows.Count, 1).End(xlUp).Offset(1, 0)
            shProperties.Range(Results1(i1)).EntireRow.Copy NextRow
        Next i1
    
    
    End Sub
    

    To detect bad addresses try adding On Error Resume Next before the For and

            If Err.Number <> 0 Then
                Err.Clear
                MsgBox "Bad Address " & Results1(i1)
            End If
    

    after the copy (inside the for loop)

    EDIT2

    Copying an EntireRow into a single cell only works if the single cell is in column A because because the EntireRow range overhangs the right hand side of the sheet.

    Use this to offset back to column A

    Set NextRow = _
        shSearchResults.Cells(shSearchResults.Rows.Count, 4).End(xlUp).Offset(1, -3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to create what I think is a relatively simple layout for
I have been trying to create a simple application that will let the user
I'm relatively new to utilizing web services. I'm trying to create one that will
I'm trying to create a relatively complex MySQL query to generate a stacked bar
I am trying to create a simple TreeView which will represent my applications data
I'm trying to get a stored procedure to work for a co-worker who is
I'm trying to create a macro that produces in-cell graphing as seen over at
I'm posting a lot of code, but the question is relatively simple: I'm trying
I'm trying to model what seems like a relatively simple referral scenario. I've tried
I am trying to do something relatively simple with iTextSharp, but I always find

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.