PIsabel
Board Regular
- Joined
- Feb 4, 2014
- Messages
- 126
- Office Version
- 365
- Platform
- Windows
How can I speed up this code?
Data is entered in column A between lines 3:1001.
Between the DT:LU columns I have sets of 7 columns that I use to process and divide the data entered in column A (DT3:DZ1001 | EA3:EG1001 and so on until LO3:LU1001)
If any row in column A has no data, all columns in that row are "empty".
If any row in column A has data, I always have at least one set of columns with data, but the number of sets with data always depends on the data entered (I can have a set or 10 or 20 or all sets of columns, from that row with data )
I can have rows with data interspersed with empty rows
The code I have does all this but it takes a long time and sometimes crashes.
Basically I have to simplify the code.
The code has to copy the lines with data, paste them into the "Components" sheet in columns A:G without blank lines because I use these lines to import data into another program and if there are empty lines it gives an error
Data is entered in column A between lines 3:1001.
Between the DT:LU columns I have sets of 7 columns that I use to process and divide the data entered in column A (DT3:DZ1001 | EA3:EG1001 and so on until LO3:LU1001)
If any row in column A has no data, all columns in that row are "empty".
If any row in column A has data, I always have at least one set of columns with data, but the number of sets with data always depends on the data entered (I can have a set or 10 or 20 or all sets of columns, from that row with data )
I can have rows with data interspersed with empty rows
The code I have does all this but it takes a long time and sometimes crashes.
Basically I have to simplify the code.
The code has to copy the lines with data, paste them into the "Components" sheet in columns A:G without blank lines because I use these lines to import data into another program and if there are empty lines it gives an error
VBA Code:
Sheets("Componentes").Range("A2:G1000").Value = Range("DT3:DZ1001").Value
Sheets("Componentes").Range("A1001:G1999").Value = Range("EA3:EG1001").Value
Sheets("Componentes").Range("A2000:G2998").Value = Range("EH3:EN1001").Value
Sheets("Componentes").Range("A2999:G3997").Value = Range("EO3:EU1001").Value
Sheets("Componentes").Range("A3998:G4996").Value = Range("EV3:FB1001").Value
Sheets("Componentes").Range("A4997:G5995").Value = Range("FC3:FI1001").Value
Sheets("Componentes").Range("A5996:G6994").Value = Range("FJ3:FP1001").Value
Sheets("Componentes").Range("A6995:G7993").Value = Range("FQ3:FW1001").Value
Sheets("Componentes").Range("A7994:G8992").Value = Range("FX3:GD1001").Value
Sheets("Componentes").Range("A8993:G9991").Value = Range("GE3:GK1001").Value
Sheets("Componentes").Range("A9992:G10990").Value = Range("GL3:GR1001").Value
Sheets("Componentes").Range("A10991:G11989").Value = Range("GS3:GY1001").Value
Sheets("Componentes").Range("A11990:G12988").Value = Range("GZ3:HF1001").Value
Sheets("Componentes").Range("A12989:G13987").Value = Range("HG3:HM1001").Value
Sheets("Componentes").Range("A13988:G14986").Value = Range("HN3:HT1001").Value
Sheets("Componentes").Range("A14987:G15985").Value = Range("HU3:IA1001").Value
Sheets("Componentes").Range("A15986:G16984").Value = Range("IB3:IH1001").Value
Sheets("Componentes").Range("A16985:G17983").Value = Range("II3:IO1001").Value
Sheets("Componentes").Range("A17984:G18982").Value = Range("IP3:IV1001").Value
Sheets("Componentes").Range("A18983:G19981").Value = Range("IW3:JC1001").Value
Sheets("Componentes").Range("A19982:G20980").Value = Range("JD3:JJ1001").Value
Sheets("Componentes").Range("A20981:G21979").Value = Range("JK3:JQ1001").Value
Sheets("Componentes").Range("A21980:G22978").Value = Range("JR3:JX1001").Value
Sheets("Componentes").Range("A22979:G23977").Value = Range("JY3:KE1001").Value
Sheets("Componentes").Range("A23978:G24976").Value = Range("KF3:KL1001").Value
Sheets("Componentes").Range("A24977:G25975").Value = Range("KM3:KS1001").Value
Sheets("Componentes").Range("A25976:G26974").Value = Range("KT3:KZ1001").Value
Sheets("Componentes").Range("A26975:G27973").Value = Range("LA3:LG1001").Value
Sheets("Componentes").Range("A27974:G28972").Value = Range("LH3:LN1001").Value
Sheets("Componentes").Range("A28973:G29971").Value = Range("LO3:LU1001").Value
'delete empty lines
On Error Resume Next
[A:A].AutoFilter Field:=1, Criteria1:="="
[A2:A29971].SpecialCells(xlVisible).EntireRow.Delete
If [A1] = "" Then [1:1].Delete
ActiveSheet.AutoFilterMode = False