Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. | Excel Worksheet Functions | |||
Copying the repeated data of the previous sheet to the next sheet | Excel Discussion (Misc queries) | |||
Dynamic column chart - copying from Sheet to Sheet. | Excel Discussion (Misc queries) | |||
Dynamic column chart - copying from Sheet to Sheet. | Charts and Charting in Excel | |||
2 questions, copying data from sheet to sheet and assigning macro | Excel Worksheet Functions |