View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
alainB[_21_] alainB[_21_] is offline
external usenet poster
 
Posts: 1
Default How to improve this code?

Hi,

I save all the data of each invoice in one row of my DATA sheet. Belo
is my sub doing that. In fact, it is much bigger, I truncated it a bi
in this example.

I offset one column for each individual data of the invoice.

I suspect that:

ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("L12")

is not the ultimate way of doing it. But it is working fine. I jus
want to improve my coding as much as I can.

Any suggestions?

Thanks!

Alain



Sub Save_And_New_Invoice()
Dim Line
Application.ScreenUpdating = False
Sheets("Data").Visible = True
Sheets("Data").Select
Line = LastLine(Sheets("Data"))

Range("A1").Select
ActiveCell.Offset(Line, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("L6")
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("L12")
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("E12")
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("E13")
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = Sheets("invoice").Range("E14")

Range("A1").Select
Sheets("Invoice").Select
ActiveWorkbook.Save
Sheets("Data").Visible = False
Application.ScreenUpdating = True
Application.Run "New_Invoice"
End Su

--
Message posted from http://www.ExcelForum.com