home page
Questions? E-mail us or call us 302-584-1771, 8AM to 10PM U.S. East Coast Time 7 days a week


Money back

How to copy a specific column

Question - issue:  The user wanted to have his user type in a week number (1 to 52)  to another sheet in the same workbook based on the column number

Sub CopyColumn()
      Dim C As Integer
            'Get the column number
            C = Application.InputBox(prompt:="Enter the week number", Type:=1)
            'exit if cancel selected
            If C = False Then Exit Sub
            'confirm number is betweeen 1 and 52
            If C >= 1 And C <= 52 Then Exit Do

      'Copy the column to the destination sheet
      ActiveCell.EntireColumn.Copy Sheets("sheet2").Columns(C)
      'clear copy/paste buffer
      Application.CutCopyMode = False
End Sub

Copyright 2018 LLC, all rights reserved.  Spreadsheet Assistant is a registered trademark of LLC.