Results 1 to 7 of 7

Excel VBA macro to select range separated by blank row and copy to next empty column

Threaded View

hackini Excel VBA macro to select... 01-29-2013, 12:50 AM
hackini Re: Excel VBA macro to select... 01-29-2013, 01:12 AM
hackini Re: Excel VBA macro to select... 01-29-2013, 01:29 AM
jindon Re: Excel VBA macro to select... 01-29-2013, 01:34 AM
hackini Re: Excel VBA macro to select... 01-29-2013, 01:52 AM
jindon Re: Excel VBA macro to select... 01-29-2013, 02:02 AM
hackini Re: Excel VBA macro to select... 01-29-2013, 02:13 AM
  1. #3
    Registered User
    Join Date
    01-29-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Excel VBA macro to select range separated by blank row and copy to next empty column

    Ok, I tried this is kinda what I need except colums and not rows.

    Sub Copy()
        Dim lastRow As Long, i As Long
        Dim CopyRange As Range
    
        With Sheets("Sheet3")
            lastRow = .Range("B" & .Rows.Count).End(xlUp).Row
    
            For i = 1 To lastRow
                If Len(Trim(.Range("B" & i).Value)) <> 0 Then
                    If CopyRange Is Nothing Then
                        Set CopyRange = .Rows(i)
                    Else
                        Set CopyRange = Union(CopyRange, .Rows(i))
                    End If
                End If
            Next
    
            If Not CopyRange Is Nothing Then
                CopyRange.Copy Sheets("Sheet5").Rows(1)
            End If
        End With
    End Sub
    Thanks again...
    Last edited by hackini; 01-29-2013 at 01:38 AM.

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