+ Reply to Thread
Results 1 to 3 of 3

How to select an entire column after a certain row macro

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2016
    Location
    Blackpool
    MS-Off Ver
    2013
    Posts
    6

    How to select an entire column after a certain row macro

    Hey guys here is my code which works fine, however could anyone point me in the right direction of how I copy the entire column
    but after for example row 3.

    so for example if I wanted to copy column A but after row 3, I hope that makes sense.

    code I have is below.

    Sub HorizontalLoop()
        Dim lCol As Long
        
         
         Sheets("output").Select
        For lCol = 1 To 100
        
    Dim inputrange As String
    
    
    
        If Not IsEmpty(Cells(lCol).Value) Then
        inputrange = Cells(1, lCol).Value
        
        
        Cells(1, lCol).EntireColumn.Select
        Selection.Copy
        Sheets("input").Select
        ActiveSheet.range(inputrange).Select
        ActiveSheet.Paste
        Sheets("output").Select
        
           End If
           
        Next lCol
    End Sub
    any help would be much appreciated

    Thanks
    H

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: How to select an entire column after a certain row macro

    if I wanted to copy column A but after row 3
    Like so:

    Range("A3:A" & Cells(Rows.Count, "A").End(xlup).Row).Copy
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to select an entire column after a certain row macro

    Try this...

    Sub HorizontalLoop()
        
        Dim lCol       As Long
        Dim inputrange As String
        
        With Sheets("output")
            For lCol = 1 To 100
                inputrange = .Cells(1, lCol).Value
                If inputrange <> "" Then
                    .Range(.Cells(3, lCol), .Cells(Rows.Count, lCol).End(xlUp)).Copy _
                        Destination:=Sheets("input").Range(inputrange)
                End If
            Next lCol
        End With
        
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CTRL+Spacebar not working to select entire column?
    By MetroBOS in forum Excel General
    Replies: 6
    Last Post: 06-15-2023, 07:26 PM
  2. Replies: 12
    Last Post: 09-16-2015, 12:35 PM
  3. Need help using VBA to select entire column as Range
    By Roxie#2013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2014, 04:16 PM
  4. How to select entire rows by specific column value?
    By gabrielemucho in forum Excel General
    Replies: 5
    Last Post: 09-09-2014, 08:06 AM
  5. select an entire column except the merged cells
    By alexcrofut in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2014, 04:12 PM
  6. select entire column based on cell value
    By jcfrancisco in forum Excel General
    Replies: 5
    Last Post: 09-26-2011, 09:47 AM
  7. Select entire column for max function
    By ssu95bm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2011, 10:36 AM

Tags for this Thread

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