+ Reply to Thread
Results 1 to 8 of 8

Select next blank row

Hybrid View

  1. #1
    Registered User
    Join Date
    12-07-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2003
    Posts
    4

    Select next blank row

    Hi,

    how do I select next blank row?

    This is what I've tried... but over writes previously pasted data.

    Sub copyinvoicedatatosalesledger()
    '
    ' copyinvoicedatatosalesledger Macro
    '
    ' Keyboard Shortcut: Ctrl+q
    '
    Application.ScreenUpdating = False
    If Range("A2") <> "" Then
    Selection.End(xlDown).Select
    
    End If
    Sheets("Sales Ledger").Select
    Range("I2:N6").Select
    Selection.CurrentRegion.Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Range("I2:N6").Select
    Selection.Copy
    ActiveWindow.SmallScroll ToRight:=-2
    Range("A2:F6").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub
    Attached Files Attached Files
    Last edited by AldenH123; 12-14-2010 at 05:46 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Select next blank row

    You don't need to Select, what is your code doing? Also, you shouldn't switch screenupdating off without restoring it
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-07-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Select next blank row

    Thanks Roy.

    Quote Originally Posted by royUK View Post
    You don't need to Select, what is your code doing? Also, you shouldn't switch screenupdating off without restoring it

    I'm trying to find the first blank row in a worksheet and then copy data to the list... this is nearly right, but takes me to the last row with text.

    Sheets("Sheet1").Select
    If Range("A1") <> "" Then Selection.End(xlDown).Select

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Select next blank row

    You aren't answering what i asked.

    This will find the last used cell in Column A, +1 to get the next empty oner.
    Dim NextRw As Long
    With Sheets("Sheet1")
    'find last used cell in Column A
    NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
    End With
    I've asked what the whole code is doing so that i can suggest code
    Last edited by royUK; 12-15-2010 at 09:36 AM.

  5. #5
    Registered User
    Join Date
    11-18-2010
    Location
    Johannesburg South Africa
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Select next blank row

    Hi,
    Ad the statement selection.offset(1,0).select
    All those select statements are not necessary.
    I suspect you you used the Macro recorder to obtain the code
    Rebards
    DAN

  6. #6
    Registered User
    Join Date
    12-07-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Select next blank row

    Quote Originally Posted by DanExel View Post
    Hi,
    Ad the statement selection.offset(1,0).select
    All those select statements are not necessary.
    I suspect you you used the Macro recorder to obtain the code
    Rebards
    DAN
    Cheers Dan, yes, I did use the Macro recorder function... I'm a newbie trying his best to learn.

    Really appreciate your help

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Select next blank row

    You should also note that a table of data like your sales ledger should have no completely empty rows. Proper use of Excel here & I doubt if you would need VBA
    Last edited by royUK; 12-15-2010 at 09:42 AM.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Select next blank row

    You won't learn unless you read replies & provide information when asked.

+ 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