How do I copy large ranges between workbooks efficiently? - debugging

i'm writing a copy paste function for a fairly large dataset to be copied from one workbook to a specific sheet in another. I have written the bellow code, in the hope that it will copy paste as efficiently as possible, however during debugging the code was shown not to be working at all, it doesnt copy or paste anything and I dont understand why, does anyone have any ideas / solutions? thanks in advance
Windows("TempResults.xlsm").Activate
numofrows = ActiveSheet.UsedRange.Rows.Count
Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A2", "AE" & CStr(numofrows)).Copy Destination:=Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1").End(xlDown).Offset(1, 0)

I guess this is what you want
Windows("TempResults.xlsm").Activate
numofrows = ActiveSheet.UsedRange.Rows.Count
Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A2", "AE" & CStr(numofrows)).Copy Destination:=Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1")

Regarding the efficiency concern expressed in your question: you can try an alternative approach, like the following:
Workbooks("Excel Results Extractor V2.xlsm").Sheets("Gate_Results").Range("A1").Value = Workbooks("TempResults.xlsm").Sheets("Sheet1").Range("A1").Value
Try to see how it works, then modify the range correspondingly to your case.
Hope this will help. Regards,

Related

Add sample names to s.class

So I'm trying to add sample names to my PCA s.class. Someone here (on another question) suggested adding text() to it, but I can't seem to figure out how to align the two.
Here is my code:
s.class(pca1$li, fac = beardata$pop, xax=1, yax=2)
add.scatter.eig(pca1$eig[1:20], 3,1,2, pos="bottomright", inset=.01, ratio=.18)
first code image
s.class(pca1$li, fac = beardata$pop)
text(pca1$li,labels=indNames(beardata),cex=0.7)
add.scatter.eig(pca1$eig[1:20], 3,1,2, pos="bottomright", inset=.01, ratio=.18)
This is what I get with added text()
Thank you for any help, I'm quite new at this so I hope this has easy solution.

ImportXML Xpath Query Return txt

I need to use Google Spreadsheet ImportXML return a value from this website...
http://www.e-go.com.au/calculatorAPI2?pickuppostcode=2000&pickupsuburb=SYDNEY+CITY&deliverypostcode=4000&deliverysuburb=BRISBANE&type=Carton&width=40&height=35&depth=65&weight=2&items=3
the website simply displays the below in text and code...
error=OK
eta=Overnight
price=64.69
I need to return the values after last line 'price=', being a newbee I'm struggling with xpath query (?) required to make this happens...
=importxml("url",?)
Your help is greatly appreciated.
Thank you in advance.
Regards
first of all, IMPORTXML() won't work because your webpage is not formatted correctly for XML, and google sheets doesn't like it.
All hope is not lost tho, as your output is so simple. you can simply load the whole output using IMPORTDATA() and then process within google sheets
have a look at the output of the following formulae (where the url is stored in A1)
=IMPORTDATA(A1)
=transpose(IMPORTDATA(A1))
=index(IMPORTDATA(A1),3,1) - IF there are always 3 results, and price will always be in the third one this will work
=filter(IMPORTDATA(A1),left(IMPORTDATA(A1),5)="price") - if the price can appear in any of the result lines, but always starting with "price"

Generate code in code_128 format from another code

I have a list of the following codes and their corresponding codes in format code_128. I want to given a string, be able to generate the corresponging code in CODE_128 format. Based on this list, how could I generate a code_128 number to the string A4Y9387VY34, for example?
code code in code_128
A4Y9387VY34 ????
ADN38Y644YT7 9611019020018632869509
AXCW99QYTD34 9622019021500078083444
A9YQC44W9J3K 9611083009710754539701
AT8V7T3G3874 9622083021255845940154
A7K444N4FKB8 9622083033510467186874
AYCHFW448HTQ 9611005019246067403120
AY63CWBMTDCC 9622005028182439033426
ANY7TF46NGQ3 9622005031345848081170
AYY48TBVQ3FH 9611200003793988696055
AT8Q4CF4DQ9Q 9611200021606968867090
A764WYQFJWTT 9622200022706968919275
AC649ND7N8B6 9622148007265209832185
A4VDPTJ99YN4 9611148013412173923039
AHDYK498BD6T 9622148021309216149530
A4YYYNY7C3DJ 9611017021934363499071
AYG6XWVCCQ89 9622017031009914238743
A68YJHGQKCCM 9622017031138587166053
APMB7XG9XQC9 9611021011608391750002
AGP8C44Y8VYK 9622021021608111646113
A7C68B9T69XB 9622021021958603678086
AJYYWKR6BDGN 9611010022528724015883
AKMNVXDT9PYN 9622010027475034102229
AXPXMK9QMDFD 9622010031475028243694
I read a lot about it, but I didn't come to any solution. Thanks in advance!!
Well, this is a pretty open question, I will give you my suggestions:
If it is a finite list, you can use a Hash or a Dictionary, where
the keys are the Codes and map them to the corresponding value, in
your case, Code_128
Some scanners have software installed that allow you to change what
has been read to a new value, format it, etc.
If you need a bigger insight please, give us more detail about the environment you are using.
Hope that helps,
I decided to create a new answer because now I get your point. Well, if you are talking about a GS1-128 Code (please see www.gs1.org) please do not start without visiting Wikipedia info about it. as you can see, there is a thorough explanation about how to work with that type of code. That code is composed by several application identifiers followed by their corresponding values. There is a better way of encoding them by using special characters as parenthesis. Here is other info that may help you.
Hope it helps,

dynamic xpath expression

Good day, colleagues!
Tell me please, how to make a dynamic xpath-parsing:
for example, instead of writing
$domXPath->query('//*[(#id = "article-id-18")]');
-> write something like that
$domXPath->query('//*[(#id = "article-id-*")]');
, because in my case, the site's script generate (every time) a new id for block, that contains article's text?
So question, is above.
Try
$domXPath->query('//*[starts-with(#id, "article-id-")]');

Descendent-or-self in InfoPath

I want to use XPath code in an InfoPath form to sum the data in field12 when field11 is equal to IT. I tried using the following code, but it doesn't work.
number(sum(/descendant-or-self::node()/my:group12[my:field11 = "IT;"]/my:field12))
I suspect this has to do with the multilayering of groups, as shown below. Does anyone know the code that would allow me to get to the data in group12? Thanks in advance for your help.
myfields>group9>group10>group11>group12>field11 field12
Genipro
Looks like:
number(sum(/descendant-or-self::my:group12[my:field11 = 'IT;']/my:field12))
could be right.
decendant-or-self should not be necissary in this case (unless you need the expression to work even if group12 is moved).
This should work fine:
sum(/my:myfields/my:group9/my:group10/my:group11/my:group12[contains(my:field11,'IT')]/my:field12)
It doesn't matter if any of the other groups are repeating either. All group12's will be checked.

Resources