+ Reply to Thread
Results 1 to 3 of 3

Writing text on the wrong line

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Writing text on the wrong line

    My macro is writing my text on the wrong line. The code is below. What I want to happen is A) copy line 270 under the existing data (skipping a line), B) copy the data OR write "this is nice" line under the existing data, C) copy line 270 under the existing data. What's happening is I get A,C,B instead of A,B,C. I'd appreciate help understanding why.
    'A)On the APR, copy and paste the Procedure and title
            Sheets("Sheet1").Range("A270").EntireRow.Copy Destination:=Sheets("Report").Range("A65536").End(xlUp).Offset(2, 0)
    'B)Copy and paste the data
                    Sheets("Workspace").Activate
            If Application.WorksheetFunction.CountA(Columns("A:A")) = 0 Then
                Sheets("Report").Range("A65536").End(xlUp).Offset(1, 0) = "This is nice.  All your positions match."
            Else
                Range("A1:I" & Range("I" & Rows.Count).End(xlUp).Row).Copy Sheets("Report").Range("A65536").End(xlUp).Offset(1, 0)
            End If
    
    'C)Copy and paste the Solution
            LastRow = Sheets("Report").Range("I" & Rows.Count).End(xlUp).Row    
            Sheets("Sheet1").Range("A271").EntireRow.Copy Destination:=Sheets("Report").Range("A" & LastRow).Offset(1, 0)
    UPDATE: I figured it out. It's my "Lastrow". I write my text in A, then check I for the last row. That'll do it every time. Thanks anyway.
    Last edited by jomili; 09-11-2012 at 11:31 AM. Reason: Figured it out.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Writing text on the wrong line

    attach please a sample file with current and desired situation
    If solved remember to mark Thread as solved

  3. #3
    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: Writing text on the wrong line

    Hi, pael45,

    read the UPDATE on the opening post (thread is solved by TO) - or even better: refresh before posting to see if any further information has been given.

    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

+ 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