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

Quantity
Discounts

Money back
guarantee

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

Answer:
Sub CopyColumn()
      Dim C As Integer
      Do
            '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
      Loop

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


Copyright 2024 Add-ins.com LLC, all rights reserved.  Spreadsheet Assistant is a registered trademark of Add-ins.com LLC.