ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Code (https://www.excelbanter.com/excel-programming/318498-excel-code.html)

wtpcomplab

Excel Code
 
Working on code for a spreadsheet and keep getting error on the code.
Need to switch back and forth between Worksheet s and do some cut and past.
Use the code below and it error out on the worksheet function.
It works fine on the same command prior to this section of code but will not
work here.
Please advise.

Thanks Dan



Do While ItemCounter < 13

'Sheets("Invoice").Select
' CODE ERROR
Windows("Invoice_AND_Total_Sheet.xls").Activate
Worksheets("Invoice").Cells(InvoiceSheetItemCntRow ,
InvoiceSheetItemCntClm).Select ' INVOICE ITEM 1 to 12
Selection.Copy
Worksheets("TOTAL SHEET").Cells(TotalSheetItemCntRow,
TotalSheetItemCntClm).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
TotalSheetItemCntRow = TotalSheetItemCntRow + 1
InvoiceSheetItemCntRow = InvoiceSheetItemCntRow + 1
ItemCounter = ItemCounter + 1
Loop

' SALES TOTALS

Do While SaleCounter < 6

'Sheets("Invoice").Select
' SALES TOTALS 1 to 5
' CODE ERROR
Worksheets("Invoice").Cells(InvoiceSheetTotalsCntR ow,
InvoiceSheetTotalsCntClm).Select
Selection.Copy
'Sheets("TOTAL SHEET").Select
Worksheets("TOTAL SHEETS").Range(TotalSheetTotalsCntRow,
TotalSheetTotalsCntClm).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
TotalSheetTotalsCntRow = TotalSheetTotalsCntRow + 1
InvoiceSheetTotalsCntRow = InvoiceSheetTotalsCntRow + 1
SaleCounter = SaleCounter + 1
Loop
Sheets("Invoice").Select

Bob Phillips[_6_]

Excel Code
 
Not tested (you posted incomplete code), but try this

Do While ItemCounter < 13

'Sheets("Invoice").Select
Windows("Invoice_AND_Total_Sheet.xls").Activate
Worksheets("Invoice").Cells(InvoiceSheetItemCntRow ,
InvoiceSheetItemCntClm).Copy
Worksheets("TOTAL SHEET").Cells(TotalSheetItemCntRow,
TotalSheetItemCntClm).PasteSpecial _
Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
TotalSheetItemCntRow = TotalSheetItemCntRow + 1
InvoiceSheetItemCntRow = InvoiceSheetItemCntRow + 1
ItemCounter = ItemCounter + 1
Loop

' SALES TOTALS

Do While SaleCounter < 6

'Sheets("Invoice").Select
' SALES TOTALS 1 to 5
Worksheets("Invoice").Cells(InvoiceSheetTotalsCntR ow,
InvoiceSheetTotalsCntClm).Copy
Worksheets("TOTAL SHEETS").Range(TotalSheetTotalsCntRow,
TotalSheetTotalsCntClm).PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
TotalSheetTotalsCntRow = TotalSheetTotalsCntRow + 1
InvoiceSheetTotalsCntRow = InvoiceSheetTotalsCntRow + 1
SaleCounter = SaleCounter + 1
Loop
Sheets("Invoice").Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"wtpcomplab" wrote in message
...
Working on code for a spreadsheet and keep getting error on the code.
Need to switch back and forth between Worksheet s and do some cut and

past.
Use the code below and it error out on the worksheet function.
It works fine on the same command prior to this section of code but will

not
work here.
Please advise.

Thanks Dan



Do While ItemCounter < 13

'Sheets("Invoice").Select
' CODE ERROR
Windows("Invoice_AND_Total_Sheet.xls").Activate
Worksheets("Invoice").Cells(InvoiceSheetItemCntRow ,
InvoiceSheetItemCntClm).Select ' INVOICE ITEM 1 to 12
Selection.Copy
Worksheets("TOTAL SHEET").Cells(TotalSheetItemCntRow,
TotalSheetItemCntClm).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
TotalSheetItemCntRow = TotalSheetItemCntRow + 1
InvoiceSheetItemCntRow = InvoiceSheetItemCntRow + 1
ItemCounter = ItemCounter + 1
Loop

' SALES TOTALS

Do While SaleCounter < 6

'Sheets("Invoice").Select
' SALES TOTALS 1 to 5
' CODE ERROR
Worksheets("Invoice").Cells(InvoiceSheetTotalsCntR ow,
InvoiceSheetTotalsCntClm).Select
Selection.Copy
'Sheets("TOTAL SHEET").Select
Worksheets("TOTAL SHEETS").Range(TotalSheetTotalsCntRow,
TotalSheetTotalsCntClm).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
TotalSheetTotalsCntRow = TotalSheetTotalsCntRow + 1
InvoiceSheetTotalsCntRow = InvoiceSheetTotalsCntRow + 1
SaleCounter = SaleCounter + 1
Loop
Sheets("Invoice").Select





All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com