Autofill to last entry

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
194
Hi
I have spread sheet with formuas in columns A , H,I ,J,K and L all diferent .
The user copys and pastes data into B-G , the amount of rows varies from 2000 rows upto 10000 rows .
I would like to have a macro ( or some kind of VBA) that would insert the formulas and autofill down to the last cell with data in .
The reason being with so many formuas ( one is indirect ) the spread sheet can become slow, so would help to only enter formulas that are needed .
Could then remove the formulas making it even quicker.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Sorry I have not used that before - is this what you mean.

7099_TNs_MrExcel.xlsm
ABCDEFGHIJKLMN
1Outstanding Tns 7099 06/08/2020Lookup Ref030820
2Status Alert Key
3Completed
40 - 9 days
510 - 12 days
613 days +
7DateDocument NumberSending Cost CentreProductTotal Stock QuantityTotal Stock Average Cost ValueskuRDC SPW plus Alert StatusCommentsNo of daysAuthority numberTrailerFurther info
8421933644713 : PSP TORNADO R 7X01/07/202042193302428: KINGS LYNN644713 : PSP TORNADO R 7X1£1,243644713RDCpaper only ref discreps3737  
9324609271657 : GOJ G24MAC2010/07/202032460900884: BARBICAN271657 : GOJ G24MAC202£8271657SPWpaper only ref discreps2828  
10421055249771 : GOG CHROMECAS T V417/07/202042105507171: DIRECT CUSTOMER RETURNS249771 : GOG CHROMECAS T V41£22249771SPW 2121  
11421063249951 : APP S342SGBSP17/07/202042106307171: DIRECT CUSTOMER RETURNS249951 : APP S342SGBSP1£175249951SPW 2121  
12325033273844 : APP AIRPODS P RO18/07/202032503307171: DIRECT CUSTOMER RETURNS273844 : APP AIRPODS P RO1£150273844SPW 2020  
13437861233497 : DJI TELLO18/07/202043786107171: DIRECT CUSTOMER RETURNS233497 : DJI TELLO1£71233497SPW 2020  
14472066219633 : SAM T5 500 PR TBLESSD20/07/202047206607171: DIRECT CUSTOMER RETURNS219633 : SAM T5 500 PR TBLESSD1£71219633SPW 1818  
15341154696638 : DJI DJI MVC A IR 2 C21/07/202034115407171: DIRECT CUSTOMER RETURNS696638 : DJI DJI MVC A IR 2 C1£694696638SPWsdfasdfasdfasdfasdfa1717  
16363588733665 : FTB VERSA2PIN K21/07/202036358807171: DIRECT CUSTOMER RETURNS733665 : FTB VERSA2PIN K1£118733665SPW 1717  
Sheet2
Cell Formulas
RangeFormula
H8:H16H8=TEXT(LEFT(E8,6),REPT("0",6))
I8:I16I8=VLOOKUP(H8,SkuData!A:B,2,FALSE)
J8:J16J8=VLOOKUP(A8,(INDIRECT("'"&F$1&"'!A:K")),10,FALSE)
K8:K16K8=IF(B8="","",RIGHT($B$1,10)-B8)+1
L8:L16L8=IFERROR(VLOOKUP(A8,(INDIRECT("'"&F$1&"'!A:K")),11,FALSE),"")
M8:M16M8=IFERROR(VLOOKUP(A8,(INDIRECT("'"&F$1&"'!A:K")),12,FALSE),"")
N8:N16N8=IFERROR(VLOOKUP(A8,(INDIRECT("'"&F$1&"'!A:K")),13,FALSE),"")
A8:A16A8=C8&E8
Named Ranges
NameRefers ToCells
SkuData!RDC_SPW_SKUList.accdb=SkuData!$A$1:$C$116675I8:I16
 
Upvote 0
Once the new data has been pasted into the sheet, run this code
It inserts all the formulas, then converts them to values, raher than the formulas
VBA Code:
Sub MM1()
Dim lr As Long
lr = Cells(Rows.Count, "B").End(xlUp).Row
Range("A8:A" & lr).Formula = "=C8&E8"
Range("H8:H" & lr).Formula = "=TEXT(LEFT(E8,6),REPT(""0"",6))"
Range("I8:I" & lr).Formula = "=VLOOKUP(H8,SkuData!A:B,2,FALSE)"
Range("J8:J" & lr).Formula = "=VLOOKUP(A8,(INDIRECT(""'""&F$1&"" '!A:K"")),10,FALSE)"
Range("K8:K" & lr).Formula = "=IF(B8="""","""",RIGHT($B$1,10)-B8)+1"
Range("L8:L" & lr).Formula = "=IFERROR(VLOOKUP(A8,(INDIRECT("" '""&F$1&""'!A:K"")),11,FALSE),"""")"
Range("M8:M" & lr).Formula = "=IFERROR(VLOOKUP(A8,(INDIRECT(""'""&F$1&""'!A:K"")),12,FALSE),"""")"
Range("N8:N" & lr).Formula = "=IFERROR(VLOOKUP(A8,(INDIRECT(""'""&F$1&""'!A:K"")),13,FALSE),"""")"
With Range("A8:N" & lr)
    .Value = .Value
End With
End Sub
 
Upvote 0
Many thanks for your time , all works well thankyou , I am learning all the time
One question , how could i allso add a border round each cell that is coppied down .
 
Upvote 0
Many thanks for your time , all works well thankyou , I am learning all the time
One question , how could i allso add a border round each cell that is coppied down .
Sorry...which cells...all the cells that contain a formula??
That seems a bit of a waste of resources??
 
Upvote 0
Ok thanks for replying , will check with the end user what they want it to looke like .

Again many thanks for your time
 
Upvote 0
Keep in mind that anything you use to highlight cells, will need to be removed every time new data is pasted in
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top