PDA

View Full Version : How add new table ellement faster?



jiura
05-13-2008, 06:02 AM
Hello to all! I have a such problem. I had a table"Production" in witch user can enter production name and price. As I don't know how many items of production has user my program also has a button "Add production". This clear production type situateв in hide row below table.

The proglem is: when my user adds many production types my excel file began to add it slower and slower. I know that the most time borrow this program row:


Selection.Insert Shift:=xlDown


in this VBA code:

Rows(Str(Range("PrZat_PrZatAdd_Start").Row) + ":" + Trim(Str(Range("PrZat_PrZatAdd_Start").Row + 6))).Select
Selection.Copy
Rows(Range("PrZat_PrZatName_End").Row).Select
Selection.Insert Shift:=xlDown


Comment:
a. First two rows select my "clear production" type (1 clear production type consist of 7 rows) and copy it to clibboard
b. Then on row 3: last row in table production selected
c. Then my "clear production" pasted
THe last step "c" is very long and problem if I had a lot of such productions.

How can I add such production faster?


P.S. Calculation type during this code is manual

Application.Calculation = xlManual

Bob Phillips
05-13-2008, 06:13 AM
Can't seeing it making much difference, but your code can be optimised



Rows(Range("PrZat_PrZatAdd_Start").Row & ":" & Range("PrZat_PrZatAdd_Start").Row + 6).Copy
Rows(Range("PrZat_PrZatName_End").Row).Insert

jiura
05-13-2008, 06:16 AM
Thanks but this rows doesn't take a millisecond to be done. Only paste row takes a lot of time