Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


Hello,

I'm still having a problem copying sheet 2, in this code (named card
to the opened workbook.

Here's the code I'm working on. When I run it, I get "Subscript Out O
Range".
It runs then stops on the added worksheet, but on sheet 1.

Please, have a look:

[color=RoyalBlue]Sub test()

Columns("A:I").Copy
Workbooks.Add
Columns("A:I").PasteSpecial Paste:=xlPasteFormats
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False

Workbooks(SolidWorksheet).Activate
Sheets("card").Select
Columns("A:I").Copy
Workbooks(Book13).Activate
Sheets("Sheet2").Select
Columns("A:I").PasteSpecial Paste:=xlPasteFormats
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False
Sheets("Sheets1").Select

ActiveWorkbook.SaveAs Filename:= _
"c:\Books\" & Format(Date, "mm-dd-yyyy") & " Sunday Worksheet.xls
' _
FileFormat:=xlNormal, Password:="", WriteResPassword:=""' _
ReadOnlyRecommend:=False, CreateBackup:=False
ActiveWorkbook.Close
returnvalue = MsgBox("Don't Forget To Put All Deposit Slips In Th
Book", 64, "Secretary's Message")
If returnvalue = 1 Then 'User chose OK

End If
End Sub

Thanks,
EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=37414

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


try this macro

Sub test()
dim new_file as variant
dim p_file as variant
p_file=activeworkbook.name
Columns("A:I").Copy
Workbooks.Add
new_file=activeworkbook.name
Columns("A:I").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone,
_
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False

Workbooks(p_file).Activate
Sheets("card").Select
Columns("A:I").Copy
Workbooks(new_file).Activate
Sheets("Sheet2").Select
Columns("A:I").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone,
_
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False
Sheets("Sheets1").Select

ActiveWorkbook.SaveAs Filename:= _
"c:\Books\" & Format(Date, "mm-dd-yyyy") & " Sunday Worksheet.xls" ' _
FileFormat:=xlNormal, Password:="", WriteResPassword:=""' _
ReadOnlyRecommend:=False, CreateBackup:=False
ActiveWorkbook.Close
returnvalue = MsgBox("Don't Forget To Put All Deposit Slips In The
Book", 64, "Secretary's Message")
If returnvalue = 1 Then 'User chose OK

End If
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=374141

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


The error doesn't point to any particular place in the code. I only see
that the new workbook is opened, but the next step to copy sheet 2 of
the solidworksheet book, over to sheet 2 of the new workbook doesn't
happen.


Not sure what you mean by what is it set to. It's just a workbook that
I want to copy sheets 1 & 2 (columns A through I on both), over to a
new workbook. The rest of the codes names it with the current
date_Sunday Worksheets into a folder called books.

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=374141

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


paste this macro in module not "this workbook", There should b
sheetname called "card" in your workbook.

try this macro and let me know. If you get error again, let me kno
which line you are getting error.


Sub test()
Dim new_file As Variant
Dim p_file As Variant
p_file = ActiveWorkbook.Name
Columns("A:I").Copy
Workbooks.Add
new_file = ActiveWorkbook.Name
Columns("A:I").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone
_
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False

Workbooks(p_file).Activate
Sheets("card").Select
Columns("A:I").Copy
Workbooks(new_file).Activate
Sheets("Sheet2").Select
Columns("A:I").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone
_
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Range("D1").Select
Application.CutCopyMode = False
Sheets("Sheet1").Select

ActiveWorkbook.SaveAs Filename:= _
"c:\Books\" & Format(Date, "mm-dd-yyyy") & " Sunday Worksheet.xls" ' _
FileFormat:=xlNormal, Password:="", WriteResPassword:=""' _
ReadOnlyRecommend:=False, CreateBackup:=False
ActiveWorkbook.Close
returnvalue = MsgBox("Don't Forget To Put All Deposit Slips In Th
Book", 64, "Secretary's Message")
If returnvalue = 1 Then 'User chose OK

End If
End Su

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=37414

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


OK,

Sorry for so many replies.

It works!

After my last reply, (I finally began to think); I placed that code in
the module section, out of this workbook, and it worked fine.

Well I got an error at first, and it pointed me to
Sheets("Sheets1").Select. I just took the s out of the sheets1, and
bingo, it flew.

Thanks again for all of your support. 3

EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=374141



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying 2nd Sheet


Not sure what you mean by what is it set to

Well is it a variable?

Code
-------------------

Sub test()
Dim new_file As Workbook
Dim p_file As Workbook

Set p_file = ActiveWorkbook
Set new_file = Workbooks.Add

p_file.activsheet.Columns("A:I").Copy

new_file.ActiveSheet.Range("A1").PasteSpecial Paste:=xlPasteFormats
new_file.ActiveSheet.Range("A1").PasteSpecial Paste:=xlPasteValues

p_file.Sheets("card").Columns("A:I").Copy
new_file.Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteFormats
new_file.Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False


new_file.SaveAs Filename:= _
"c:\Books\" & Format(Date, "mm-dd-yyyy") & " Sunday Worksheet.xls" ' _
FileFormat:=xlNormal, Password:="", WriteResPassword:=""' _
ReadOnlyRecommend:=False, CreateBackup:=False
new_file.Close
MsgBox("Don't Forget To Put All Deposit Slips In The Book", 64, "Secretary's Message")

End Sub

-------------------

--
Nori
-----------------------------------------------------------------------
Norie's Profile: http://www.excelforum.com/member.php...fo&userid=1936
View this thread: http://www.excelforum.com/showthread.php?threadid=37414

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. Alex Zuniga Excel Worksheet Functions 1 November 25th 09 11:54 PM
Copying the repeated data of the previous sheet to the next sheet Sasikiran Excel Discussion (Misc queries) 1 September 25th 07 03:18 PM
Dynamic column chart - copying from Sheet to Sheet. Marko Pinteric Excel Discussion (Misc queries) 1 April 10th 06 12:57 PM
Dynamic column chart - copying from Sheet to Sheet. Marko Pinteric Charts and Charting in Excel 1 April 10th 06 12:57 PM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"