View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default How to copy selected column to another page under a specifik field?

Hi,

Am Mon, 4 Jun 2012 18:02:58 +0000 schrieb robissme:

How do you make a macro that copies the selected column to another
sheet/page in the same file, the contents of the selected column will go
in specifically for a column where a WEEKNUM be indicated. Thus, the
column is selected, the user presses for x a button where macro is run,
the user will be asked, for example, through a dialog box (To which
WEEKNUM want to copy the column to?). User types such as 23, and click
OK. 23 is actually located in as: Y:2 in another page. The column to be
copied must therefore fall directly under Y:3

(The dialogbox isnt important, the user could type the weeknum
elsewhere).
Someone who can help me?


try:

Sub myCopy()
Dim LRow As Long
Dim Answer As Integer

LRow = Sheets("Selected").Cells(Rows.Count, 1).End(xlUp).Row
Answer = Application.InputBox("Which weeknum is the destination?", _
Type:=1) 'enter only a number

If Answer = 0 Then
MsgBox "Please enter a weeknum"
Exit Sub
End If

Sheets("Selected").Range("A1:A" & LRow).Copy _
Destination:=Sheets("Copy-to").Cells(4, Answer)
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2