VBA String error

mrsushi

Board Regular
Joined
Nov 18, 2006
Messages
180
Office Version
  1. 2010
HI

Cant seem to work out the below problem. D5 - G5 is returning "FALSE" and filling down with FALSE When in fact it should be retrieving data from the sheet "LT03 Full data" tab

Any ideas of why this is happening please?



Sub NewRecon()
Dim strFormulas(4 To 7) As Variant
lngLastRow = Range("A" & Rows.Count).End(xlUp).Row

strFormulas(4) = Worksheets("LT03 Rec").Range("D5").Formula = "=IF(COUNTIF(R5C1:R50000C1,RC1)>1,""DUPLICATE"","""")"
strFormulas(5) = Worksheets("LT03 Rec").Range("E5").Formula = "=VLOOKUP(CONCATENATE(RC[-4],"" "",RC[-3]),'LT03 Full Data'!C[-4]:C[-2], 2, FALSE)"
strFormulas(6) = Worksheets("LT03 Rec").Range("F5").Formula = "=VLOOKUP(CONCATENATE(RC[-5],RC[-4]),'LT03 Full Data'!C[-5]:C[-3],2, FALSE)"
strFormulas(7) = Worksheets("LT03 Rec").Range("G5").Formula = "=VLOOKUP(CONCATENATE(RC[-6], "" "",RC[-5]),'LT03 Full Data'!C[-6]:C[-4],2, FALSE)"

Range("D5:G5").Formula = strFormulas
Range("D5:G" & lngLastRow).FillDown

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It should be like
VBA Code:
strFormulas(4) = "=IF(COUNTIF(R5C1:R50000C1,RC1)>1,""DUPLICATE"","""")"
 
Upvote 0
Many thanks for the tweak. That's sorted it out.

Do you know if this is the most efficient Script? The whole process took about a minute to complete. Im trying to find if there is another script which is faster

Many thanks
 
Upvote 0
Try putting this immediately after your Dim statement...

Application.ScreenUpdating = False

and this...

Application.ScreenUpdating = True

immediately before the End Sub statement and see if that speeds it up for you.
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,770
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