Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Cesar Gonzalez   on Sep 21 In MS Office Category.

  
Question Answered By: Jonathan Brown   on Sep 21

I figured it out.... I needed to
have "Application.Selection.PasteSpecial" rather than
just "Selection.PasteSpecial".

Working Code:
Sub test1()

Dim Wk As Workbook
Dim Wk2 As Workbook
Dim N As Integer
Dim y As Integer

Set Wk = ActiveWorkbook 'The orginal workbook  with the case data
Set Wk2 = Workbooks.Add 'The destination workbook

Wk.Activate
Sheets("PDI_DataQC").Select

y = InputBox("How Many Cases (i.e. 1-200)?")

For N = 1 To y
Wk.Activate
Range("B1").Select
ActiveCell.FormulaR1C1 = N

Sheets("PDI_DataQC").Select
Cells.Select
Selection.Copy

Wk2.Activate
ActiveWorkbook.Worksheets.Add.Name = N

Application.Selection.PasteSpecial Paste:=xlPasteValues, _'HERE'S
WHERE THE PROBLEM WAS
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next N


End Sub

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Data from a form on a worksheet in new workbook... Or get search suggestion and latest updates.


Tagged: