Excel Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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(InvoiceSheetTotalsCntRow,
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
 
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(InvoiceSheetTotalsCntRow,
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top