How to make an array of character in C - c
I am trying to make an array of character. I get this code and get error
#include<stdio.h>
#include<stdlib.h>
#include"boolean.h"
const char *skillNames[8];
skillNames[0] = "Darth Vader";
skillNames[1] = "Han Solo";
skillNames[2] = "Master Yoda";
skillNames[3] = "Luke Skywalker";
skillNames[4] = "Obi Wan Kenobi";
skillNames[5] = "Chewbacca";
skillNames[6] = "Emperor Palpatine";
skillNames[7] = "Princess Leia";
#include<stdio.h>
#include<stdlib.h>
#include"boolean.h"
int main() {
const char *skillNames[8];
skillNames[0] = "Darth Vader";
skillNames[1] = "Han Solo";
skillNames[2] = "Master Yoda";
skillNames[3] = "Luke Skywalker";
skillNames[4] = "Obi Wan Kenobi";
skillNames[5] = "Chewbacca";
skillNames[6] = "Emperor Palpatine";
skillNames[7] = "Princess Leia";
}
Put it inside a main function.
You can use the initialization syntax. You don't even need to mention the size of the array:
const char *skillNames[] = {
"Darth Vader", "Han Solo", "Master Yoda", "Luke Skywalker",
"Obi Wan Kenobi", "Chewbacca", "Emperor Palpatine", "Princess Leia",
};
Add a main() function and replace the #include"boolean.h" with #include<stdbool.h>. See if that fixes the error or not.
The full code can be like this:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{
const char *skillNames[8];
skillNames[0] = "Darth Vader";
skillNames[1] = "Han Solo";
skillNames[2] = "Master Yoda";
skillNames[3] = "Luke Skywalker";
skillNames[4] = "Obi Wan Kenobi";
skillNames[5] = "Chewbacca";
skillNames[6] = "Emperor Palpatine";
skillNames[7] = "Princess Leia";
}
Related
PQexecParams() returning ERROR: invalid input syntax for type date: ""
If fr_dt is empty - PQresultErrorMessage() return "ERROR: invalid input syntax for type date: """ My c code: string new_data = "some new data"; string fr_dt = obj.getDate(); const char *c_new_data = new_data.c_str(); const char *c_fr_dt = fr_dt.c_str(); const char* ins_data_com = "select * from ins_data($1,$2); int nParams = 2; const char *const paramValues[] = {c_new_data,c_fr_dt}; const int paramLengths[] = {sizeof(c_new_data),sizeof(c_fr_dt)}; const int paramFormats[] = {0,0}; int resultFormat = 0; PGresult res_com = PQexecParams(conn,ins_data_com, nParams, NULL, paramValues, paramLengths, paramFormats, resultFormat); and pgsql code: CREATE OR REPLACE FUNCTION ins_data(in_data text, in_date date) RETURNS int LANGUAGE plpgsql AS $function$ DECLARE n_id int; BEGIN WITH cte AS ( INSERT INTO public.my_table (new_data, time_in) VALUES(in_data, coalesce(in_date::timestamp,current_timestamp)) RETURNING id AS new_id ) SELECT new_id INTO n_id FROM cte; RETURN n_id; END; $function$ ; How can I fix it?
Solution: const char *с_fr_dt = NULL; if (!fr_dt.empty()) { с_fr_dt = fr_dt.c_str(); }
Create and update progress bar using CFUserNotification API
The following code creates and initialises a simple progress bar using CFUserNotification API. How would I add a callback to update the progress bar ? With this code, the progress is at the constant value indicated by prog. float prog = 0.1; CFNumberRef cfNum = CFNumberCreate(kCFAllocatorDefault,kCFNumberFloatType, &prog); const void* keys[] = { kCFUserNotificationAlertHeaderKey, kCFUserNotificationProgressIndicatorValueKey }; const void* vals[] = { CFSTR("Progress Bar"), cfNum}; CFDictionaryRef dict = CFDictionaryCreate(0, keys, vals, sizeof(keys)/sizeof(*keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFUserNotificationRef pDlg = NULL; pDlg = CFUserNotificationCreate(kCFAllocatorDefault, 0, kCFUserNotificationPlainAlertLevel, &nRes, dict);
How to extract multiple numbers from string in C
I have a question. If I want to extract more than one float number in a string what should I do ? I know that there are functions like strtof by which I can extract the number. The question is what if there are more than one number existing in string? I just want and I know that only thing that is needed is pointer to the next character after finding the number. Then continue searching until it reaches \n but how? EXAMPLE: Imagine I have a report about rainfall of some towns during a year and I want to extract rainfall for each town (when it gets to the \nreport for the town is finished ). #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { char* data = "Rome:Jan 81.2,Feb 63.2,Mar 70.3,Apr 55.7,May 53.0,Jun 36.4,Jul 17.5,Aug 27.5,Sep 60.9,Oct 117.7,Nov 111.0,Dec 97.9\n" "London:Jan 48.0,Feb 38.9,Mar 39.9,Apr 42.2,May 47.3,Jun 52.1,Jul 59.5,Aug 57.2,Sep 55.4,Oct 62.0,Nov 59.0,Dec 52.9\n" "Paris:Jan 182.3,Feb 120.6,Mar 158.1,Apr 204.9,May 323.1,Jun 300.5,Jul 236.8,Aug 192.9,Sep 66.3,Oct 63.3,Nov 83.2,Dec 154.7\n" "NY:Jan 108.7,Feb 101.8,Mar 131.9,Apr 93.5,May 98.8,Jun 93.6,Jul 102.2,Aug 131.8,Sep 92.0,Oct 82.3,Nov 107.8,Dec 94.2\n" "Vancouver:Jan 145.7,Feb 121.4,Mar 102.3,Apr 69.2,May 55.8,Jun 47.1,Jul 31.3,Aug 37.0,Sep 59.6,Oct 116.3,Nov 154.6,Dec 171.5\n" "Sydney:Jan 103.4,Feb 111.0,Mar 131.3,Apr 129.7,May 123.0,Jun 129.2,Jul 102.8,Aug 80.3,Sep 69.3,Oct 82.6,Nov 81.4,Dec 78.2\n" "Bangkok:Jan 10.6,Feb 28.2,Mar 30.7,Apr 71.8,May 189.4,Jun 151.7,Jul 158.2,Aug 187.0,Sep 319.9,Oct 230.8,Nov 57.3,Dec 9.4\n" "Tokyo:Jan 49.9,Feb 71.5,Mar 106.4,Apr 129.2,May 144.0,Jun 176.0,Jul 135.6,Aug 148.5,Sep 216.4,Oct 194.1,Nov 95.6,Dec 54.4\n" "Beijing:Jan 3.9,Feb 4.7,Mar 8.2,Apr 18.4,May 33.0,Jun 78.1,Jul 224.3,Aug 170.0,Sep 58.4,Oct 18.0,Nov 9.3,Dec 2.7\n" "Lima:Jan 1.2,Feb 0.9,Mar 0.7,Apr 0.4,May 0.6,Jun 1.8,Jul 4.4,Aug 3.1,Sep 3.3,Oct 1.7,Nov 0.5,Dec 0.7"; const char* towns[14] = {"Rome", "London", "Paris", "NY", "Vancouver", "Sydney", "Bangkok", "Tokyo", "Beijing", "Lima", "Montevideo", "Caracas", "Madrid", "Berlin"}; size_t i = 0; float nums[12]; char *ch_ptr = strstr(data,towns[0]); //pointing to first character const char *stop ="\n"; while((ch_ptr++) != stop) { nums[i] = strtof(); ///How should I do it ???? i++; } return 0; }
Using two nested for loops, the float value for each town and month can be captured. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { char* data = "Rome:Jan 81.2,Feb 63.2,Mar 70.3,Apr 55.7,May 53.0,Jun 36.4,Jul 17.5,Aug 27.5,Sep 60.9,Oct 117.7,Nov 111.0,Dec 97.9\n" "London:Jan 48.0,Feb 38.9,Mar 39.9,Apr 42.2,May 47.3,Jun 52.1,Jul 59.5,Aug 57.2,Sep 55.4,Oct 62.0,Nov 59.0,Dec 52.9\n" "Paris:Jan 182.3,Feb 120.6,Mar 158.1,Apr 204.9,May 323.1,Jun 300.5,Jul 236.8,Aug 192.9,Sep 66.3,Oct 63.3,Nov 83.2,Dec 154.7\n" "NY:Jan 108.7,Feb 101.8,Mar 131.9,Apr 93.5,May 98.8,Jun 93.6,Jul 102.2,Aug 131.8,Sep 92.0,Oct 82.3,Nov 107.8,Dec 94.2\n" "Vancouver:Jan 145.7,Feb 121.4,Mar 102.3,Apr 69.2,May 55.8,Jun 47.1,Jul 31.3,Aug 37.0,Sep 59.6,Oct 116.3,Nov 154.6,Dec 171.5\n" "Sydney:Jan 103.4,Feb 111.0,Mar 131.3,Apr 129.7,May 123.0,Jun 129.2,Jul 102.8,Aug 80.3,Sep 69.3,Oct 82.6,Nov 81.4,Dec 78.2\n" "Bangkok:Jan 10.6,Feb 28.2,Mar 30.7,Apr 71.8,May 189.4,Jun 151.7,Jul 158.2,Aug 187.0,Sep 319.9,Oct 230.8,Nov 57.3,Dec 9.4\n" "Tokyo:Jan 49.9,Feb 71.5,Mar 106.4,Apr 129.2,May 144.0,Jun 176.0,Jul 135.6,Aug 148.5,Sep 216.4,Oct 194.1,Nov 95.6,Dec 54.4\n" "Beijing:Jan 3.9,Feb 4.7,Mar 8.2,Apr 18.4,May 33.0,Jun 78.1,Jul 224.3,Aug 170.0,Sep 58.4,Oct 18.0,Nov 9.3,Dec 2.7\n" "Lima:Jan 1.2,Feb 0.9,Mar 0.7,Apr 0.4,May 0.6,Jun 1.8,Jul 4.4,Aug 3.1,Sep 3.3,Oct 1.7,Nov 0.5,Dec 0.7"; const char* months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun" , "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; const char* towns[14] = {"Rome", "London", "Paris", "NY", "Vancouver", "Sydney", "Bangkok", "Tokyo", "Beijing", "Lima", "Montevideo", "Caracas", "Madrid", "Berlin"}; size_t i = 0; float nums[12]; char *end = NULL; char *town_ptr = NULL; char *month_ptr = NULL; char monthid[100] = ""; char townid[100] = ""; for ( int town = 0; town < 14; town++) { if ( ( town_ptr = strstr ( data, towns[town]))) { i = 0; sscanf ( town_ptr, "%99[^:]", townid); for ( int month = 0; month < 12; month++) { if ( ( month_ptr = strstr ( town_ptr, months[month]))) { sscanf ( month_ptr, "%99s", monthid); month_ptr += strlen ( months[month]); nums[i] = strtof( month_ptr, &end); if ( *end == ',' || *end == '\n' || *end == '\0') { printf ( "%s %s nums[%d] = %f\n", townid, monthid, i, nums[i]); i++; } } } } } return 0; } To parse from the town name to a newline. If a month was missing from a town, the previous code would use the month from the next town. This will iterate from the town name until twelve values, a newline, a '\0' or failure to parse a double. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { char* data = "Rome:Jan 81.2,Feb 63.2,Mar 70.3,Apr 55.7,May 53.0,Jun 36.4,Jul 17.5,Aug 27.5,Sep 60.9,Oct 117.7,Nov 111.0,Dec 97.9\n" "London:Jan 48.0,Feb 38.9,Mar 39.9,Apr 42.2,May 47.3,Jun 52.1,Jul 59.5,Aug 57.2,Sep 55.4,Oct 62.0,Nov 59.0,Dec 52.9\n" "Paris:Jan 182.3,Feb 120.6,Mar 158.1,Apr 204.9,May 323.1,Jun 300.5,Jul 236.8,Aug 192.9,Sep 66.3,Oct 63.3,Nov 83.2,Dec 154.7\n" "NY:Jan 108.7,Feb 101.8,Mar 131.9,Apr 93.5,May 98.8,Jun 93.6,Jul 102.2,Aug 131.8,Sep 92.0,Oct 82.3,Nov 107.8,Dec 94.2\n" "Vancouver:Jan 145.7,Feb 121.4,Mar 102.3,Apr 69.2,May 55.8,Jun 47.1,Jul 31.3,Aug 37.0,Sep 59.6,Oct 116.3,Nov 154.6,Dec 171.5\n" "Sydney:Jan 103.4,Feb 111.0,Mar 131.3,Apr 129.7,May 123.0,Jun 129.2,Jul 102.8,Aug 80.3,Sep 69.3,Oct 82.6,Nov 81.4,Dec 78.2\n" "Bangkok:Jan 10.6,Feb 28.2,Mar 30.7,Apr 71.8,May 189.4,Jun 151.7,Jul 158.2,Aug 187.0,Sep 319.9,Oct 230.8,Nov 57.3,Dec 9.4\n" "Tokyo:Jan 49.9,Feb 71.5,Mar 106.4,Apr 129.2,May 144.0,Jun 176.0,Jul 135.6,Aug 148.5,Sep 216.4,Oct 194.1,Nov 95.6,Dec 54.4\n" "Beijing:Jan 3.9,Feb 4.7,Mar 8.2,Apr 18.4,May 33.0,Jun 78.1,Jul 224.3,Aug 170.0,Sep 58.4,Oct 18.0,Nov 9.3,Dec 2.7\n" "Lima:Jan 1.2,Feb 0.9,Mar 0.7,Apr 0.4,May 0.6,Jun 1.8,Jul 4.4,Aug 3.1,Sep 3.3,Oct 1.7,Nov 0.5,Dec 0.7"; const char* towns[14] = {"Rome", "London", "Paris", "NY", "Vancouver", "Sydney", "Bangkok", "Tokyo", "Beijing", "Lima", "Montevideo", "Caracas", "Madrid", "Berlin"}; float nums[12]; char *end = NULL; char *town_ptr = NULL; char monthid[100] = ""; char townid[100] = ""; int span = 0; for ( int town = 0; town < 14; town++) { if ( ( town_ptr = strstr ( data, towns[town]))) {//find the town name sscanf ( town_ptr, "%99[^:]:%n", townid, &span); int each = 0; town_ptr += span; do { sscanf ( town_ptr, "%s%n", monthid, &span); town_ptr += span; nums[each] = strtod ( town_ptr, &end); if ( end == town_ptr) {//failed to parse a double break; } printf ( "%s %s nums[%d] = %f\n", townid, monthid, each, nums[each]); town_ptr = end + 1;//to advance past the comma each++; } while ( each < 12 && *end != '\0' && *end != '\n'); } } return 0; }
Filter 2 struct/ arrays by mapping by specific
Im a new user using swift 3 and xcode 8.3. Currently facing a problem to filter 2 array/struc where in console output as below: A_List : Optional([117, 115, 18]) B_List : Optional([{ URL = "169.jpeg"; categories = "A"; description = "description XXX"; height = 128; id = 1; likes = "1.00"; name = "Cake - Baked"; price = "13.78"; width = 128; }, { URL = "1622.jpeg"; categories = "A"; description = "Baked till golden"; height = 128; id = 15; likes = "1.00"; name = "Croissant"; price = "3.71"; width = 128; }, { URL = "11.jpeg"; categories = "A"; description = "description Crispy."; height = 128; id = 18; likes = "1.00"; name = "Plain"; price = "2.65"; width = 128; }, { URL = "1622.jpeg"; categories = "A"; description = "A "; height = 128; id = 103; likes = "1.00"; name = "America Pie"; price = "2.12"; width = 128; }, { URL = "11.jpeg"; categories = "B"; description = "Puff"; height = 128; id = 115; likes = "1.00"; name = "Puff"; price = "2.12"; width = 128; }, { URL = "168.jpeg"; categories = "C"; description = "description YYY"; height = 128; id = 117; likes = "1.00"; name = "Normal"; price = "3.18"; width = 128; }]) I want to return B_List full info as var filtered_List = [AnyObject]() where only contains of A_List id number 117, 115, and 18 which look like as below: filtered_List : Optional([{ URL = "11.jpeg"; categories = "A"; description = "description Crispy."; height = 128; id = 18; likes = "1.00"; name = "Plain"; price = "2.65"; width = 128; }, { URL = "11.jpeg"; categories = "B"; description = "Puff"; height = 128; id = 115; likes = "1.00"; name = "Mini Puff"; price = "2.12"; width = 128; }, { URL = "168.jpeg"; categories = "C"; description = "description YYY"; height = 128; id = 117; likes = "1.00"; name = "Normal"; price = "3.18"; width = 128; }]) I have tried few code and read tutorial in youtube, but unfortunately did not find any solution and it limited to swift2 sample. Currently, my code tried as below: var filtered_List = [AnyObject]() let fullrList = B_List?.map{$0["id"] as! String}.map{_ in A_List} filtered_List.append(fullrList as AnyObject ) print("result :\(filtered_List)") Very Appreciated if someone expert can guide or give your solution here.
You should store your desired IDs in a Set, rather than an Array. You're just need a simple filter operation: let desiredIds: Set = [117, 115, 18] B_List.filter{ $0["id"].map{ desiredIds.contains($0) } ?? false } as [AnyObject]
Thanks for everyone who reply this topic specially to #Alexander. Here my solutions to share that may not the perfect one as others. var resultAnyObject = [AnyObject]() var aListIds = [String]() for i in A_List! { aListIds.append(i as! String) } //#Alexander : thanks for code below: let desiredIds = aListIds let fullList = B_List?.filter{ $0["id"].map{desiredIds.contains($0 as! String) } ?? false }; resultAnyObject.append(fullList as AnyObject) print("Result of filtered_List :\(resultAnyObject)")
Most Efficient Ways To Compare Multiple Array Values in VBA?
Before I begin, let me say that I know this probably isn't best done in excel and VBA, but my hands are tied in that regard. I have a spreadsheet of 29 columns (always), and anywhere between 100 and 10,000 rows each day. I need a way to automatically move rows from one sheet to another based on multiple criteria. The basic logic is that it needs to search the first sheet, and if C OR D equal a certain text value, AND Y contains a certain numeric value, it needs to be added to the second sheet and removed from the first. The problem is that I've built a test version that only looks at ONE of the three criteria, and it is already very slow - If I had two more arrays and if/and/or logic, I don't think this is going to be usable on the 10,000 row days. What can I do to speed this up? I feel like there has to be a better/faster way than arrays and for loops. I'm very much a novice, so I'm sure this is a very bad solution. Option Explicit Sub MacroSoFar() Dim lColumnLength As Long Dim intArrayCounter As Integer Dim TestArray(165) As String TestArray(0) = "4" TestArray(1) = "5" TestArray(2) = "6" TestArray(3) = "7" TestArray(4) = "8" TestArray(5) = "9" TestArray(6) = "10" TestArray(7) = "11" TestArray(8) = "12" TestArray(9) = "14" TestArray(10) = "19" TestArray(11) = "20" TestArray(12) = "21" TestArray(13) = "25" TestArray(14) = "30" TestArray(15) = "35" TestArray(16) = "36" TestArray(17) = "37" TestArray(18) = "41" TestArray(19) = "42" TestArray(20) = "43" TestArray(21) = "46" TestArray(22) = "47" TestArray(23) = "48" TestArray(24) = "51" TestArray(25) = "52" TestArray(26) = "53" TestArray(27) = "60" TestArray(28) = "63" TestArray(29) = "65" TestArray(30) = "66" TestArray(31) = "67" TestArray(32) = "68" TestArray(33) = "69" TestArray(34) = "70" TestArray(35) = "71" TestArray(36) = "72" TestArray(37) = "73" TestArray(38) = "74" TestArray(39) = "75" TestArray(40) = "76" TestArray(41) = "77" TestArray(42) = "78" TestArray(43) = "79" TestArray(44) = "80" TestArray(45) = "81" TestArray(46) = "82" TestArray(47) = "83" TestArray(48) = "84" TestArray(49) = "85" TestArray(50) = "86" TestArray(51) = "87" TestArray(52) = "88" TestArray(53) = "89" TestArray(54) = "90" TestArray(55) = "91" TestArray(56) = "92" TestArray(57) = "93" TestArray(58) = "94" TestArray(59) = "96" TestArray(60) = "97" TestArray(61) = "98" TestArray(62) = "99" TestArray(63) = "101" TestArray(64) = "102" TestArray(65) = "103" TestArray(66) = "106" TestArray(67) = "107" TestArray(68) = "108" TestArray(69) = "109" TestArray(70) = "111" TestArray(71) = "112" TestArray(72) = "113" TestArray(73) = "115" TestArray(74) = "116" TestArray(75) = "117" TestArray(76) = "118" TestArray(77) = "121" TestArray(78) = "122" TestArray(79) = "125" TestArray(80) = "129" TestArray(81) = "130" TestArray(82) = "131" TestArray(83) = "132" TestArray(84) = "133" TestArray(85) = "134" TestArray(86) = "137" TestArray(87) = "138" TestArray(88) = "142" TestArray(89) = "143" TestArray(90) = "144" TestArray(91) = "145" TestArray(92) = "146" TestArray(93) = "147" TestArray(94) = "155" TestArray(95) = "156" TestArray(96) = "157" TestArray(97) = "158" TestArray(98) = "159" TestArray(99) = "161" TestArray(100) = "162" TestArray(101) = "169" TestArray(102) = "170" TestArray(103) = "173" TestArray(104) = "174" TestArray(105) = "175" TestArray(106) = "176" TestArray(107) = "180" TestArray(108) = "181" TestArray(109) = "182" TestArray(110) = "183" TestArray(111) = "184" TestArray(112) = "185" TestArray(113) = "186" TestArray(114) = "187" TestArray(115) = "188" TestArray(116) = "189" TestArray(117) = "190" TestArray(118) = "192" TestArray(119) = "193" TestArray(120) = "194" TestArray(121) = "195" TestArray(122) = "196" TestArray(123) = "201" TestArray(124) = "202" TestArray(125) = "205" TestArray(126) = "206" TestArray(127) = "207" TestArray(128) = "208" TestArray(129) = "211" TestArray(130) = "212" TestArray(131) = "214" TestArray(132) = "215" TestArray(133) = "217" TestArray(134) = "218" TestArray(135) = "220" TestArray(136) = "221" TestArray(137) = "222" TestArray(138) = "223" TestArray(139) = "224" TestArray(140) = "225" TestArray(141) = "226" TestArray(142) = "228" TestArray(143) = "229" TestArray(144) = "230" TestArray(145) = "235" TestArray(146) = "236" TestArray(147) = "237" TestArray(148) = "240" TestArray(149) = "241" TestArray(150) = "242" TestArray(151) = "244" TestArray(152) = "249" TestArray(153) = "250" TestArray(154) = "251" TestArray(155) = "255" TestArray(156) = "256" TestArray(157) = "259" TestArray(158) = "260" TestArray(159) = "262" TestArray(160) = "263" TestArray(161) = "264" TestArray(162) = "265" TestArray(163) = "266" TestArray(164) = "267" TestArray(165) = "269" For intArrayCounter = 0 To 165 Step 1 For lColumnLength = Cells(Rows.Count, 25).End(xlUp).Row To 1 Step -1 If InStr(Cells(lColumnLength, 25), TestArray(intArrayCounter)) > 0 Then Range("a" & lColumnLength & ":AC" & lColumnLength).Copy Sheet10.Cells(Rows.Count, 1).End(xlUp).Offset(1) Cells(lColumnLength, 29).EntireRow.Delete End If Next Next End Sub
I haven't tested this, but I got to run. But it may give you some food for thought. Option Explicit Sub MacroSoFar() Dim lColumnLength As Long Dim intArrayCounter As Integer Dim TestArray(165) As String TestArray(0) = "4" TestArray(1) = "5" TestArray(2) = "6" TestArray(3) = "7" TestArray(4) = "8" TestArray(5) = "9" TestArray(6) = "10" TestArray(7) = "11" TestArray(8) = "12" TestArray(9) = "14" TestArray(10) = "19" TestArray(11) = "20" TestArray(12) = "21" TestArray(13) = "25" TestArray(14) = "30" TestArray(15) = "35" TestArray(16) = "36" TestArray(17) = "37" TestArray(18) = "41" TestArray(19) = "42" TestArray(20) = "43" TestArray(21) = "46" TestArray(22) = "47" TestArray(23) = "48" TestArray(24) = "51" TestArray(25) = "52" TestArray(26) = "53" TestArray(27) = "60" TestArray(28) = "63" TestArray(29) = "65" TestArray(30) = "66" TestArray(31) = "67" TestArray(32) = "68" TestArray(33) = "69" TestArray(34) = "70" TestArray(35) = "71" TestArray(36) = "72" TestArray(37) = "73" TestArray(38) = "74" TestArray(39) = "75" TestArray(40) = "76" TestArray(41) = "77" TestArray(42) = "78" TestArray(43) = "79" TestArray(44) = "80" TestArray(45) = "81" TestArray(46) = "82" TestArray(47) = "83" TestArray(48) = "84" TestArray(49) = "85" TestArray(50) = "86" TestArray(51) = "87" TestArray(52) = "88" TestArray(53) = "89" TestArray(54) = "90" TestArray(55) = "91" TestArray(56) = "92" TestArray(57) = "93" TestArray(58) = "94" TestArray(59) = "96" TestArray(60) = "97" TestArray(61) = "98" TestArray(62) = "99" TestArray(63) = "101" TestArray(64) = "102" TestArray(65) = "103" TestArray(66) = "106" TestArray(67) = "107" TestArray(68) = "108" TestArray(69) = "109" TestArray(70) = "111" TestArray(71) = "112" TestArray(72) = "113" TestArray(73) = "115" TestArray(74) = "116" TestArray(75) = "117" TestArray(76) = "118" TestArray(77) = "121" TestArray(78) = "122" TestArray(79) = "125" TestArray(80) = "129" TestArray(81) = "130" TestArray(82) = "131" TestArray(83) = "132" TestArray(84) = "133" TestArray(85) = "134" TestArray(86) = "137" TestArray(87) = "138" TestArray(88) = "142" TestArray(89) = "143" TestArray(90) = "144" TestArray(91) = "145" TestArray(92) = "146" TestArray(93) = "147" TestArray(94) = "155" TestArray(95) = "156" TestArray(96) = "157" TestArray(97) = "158" TestArray(98) = "159" TestArray(99) = "161" TestArray(100) = "162" TestArray(101) = "169" TestArray(102) = "170" TestArray(103) = "173" TestArray(104) = "174" TestArray(105) = "175" TestArray(106) = "176" TestArray(107) = "180" TestArray(108) = "181" TestArray(109) = "182" TestArray(110) = "183" TestArray(111) = "184" TestArray(112) = "185" TestArray(113) = "186" TestArray(114) = "187" TestArray(115) = "188" TestArray(116) = "189" TestArray(117) = "190" TestArray(118) = "192" TestArray(119) = "193" TestArray(120) = "194" TestArray(121) = "195" TestArray(122) = "196" TestArray(123) = "201" TestArray(124) = "202" TestArray(125) = "205" TestArray(126) = "206" TestArray(127) = "207" TestArray(128) = "208" TestArray(129) = "211" TestArray(130) = "212" TestArray(131) = "214" TestArray(132) = "215" TestArray(133) = "217" TestArray(134) = "218" TestArray(135) = "220" TestArray(136) = "221" TestArray(137) = "222" TestArray(138) = "223" TestArray(139) = "224" TestArray(140) = "225" TestArray(141) = "226" TestArray(142) = "228" TestArray(143) = "229" TestArray(144) = "230" TestArray(145) = "235" TestArray(146) = "236" TestArray(147) = "237" TestArray(148) = "240" TestArray(149) = "241" TestArray(150) = "242" TestArray(151) = "244" TestArray(152) = "249" TestArray(153) = "250" TestArray(154) = "251" TestArray(155) = "255" TestArray(156) = "256" TestArray(157) = "259" TestArray(158) = "260" TestArray(159) = "262" TestArray(160) = "263" TestArray(161) = "264" TestArray(162) = "265" TestArray(163) = "266" TestArray(164) = "267" TestArray(165) = "269" Dim oSheet As Variant, nSheet As Variant, oList As New Collection, nList As New Collection oSheet = Range("A1:AC" & Cells(Rows.Count, 25).End(xlUp).Row).Value For intArrayCounter = 0 To 165 Step 1 For lColumnLength = Cells(Rows.Count, 25).End(xlUp).Row To 1 Step -1 If InStr(oSheet(lColumnLength, 25), TestArray(intArrayCounter)) > 0 Then ' Add to list in order nList.Add Range("a" & lColumnLength & ":AC" & lColumnLength).Value Else ' Add to list in reverse order oList.Add Range("a" & lColumnLength & ":AC" & lColumnLength).Value End If Next Next For i = oList.Count To 1 Step -1 For j = 1 To 29 oSheet(i, j) = oList(i)(1, j) Next j Next i Range("A1:AC" & Cells(Rows.Count, 25).End(xlUp).Row) = oSheet Range("A" & oList.Count + 1 & ":A" & Cells(Rows.Count, 25).End(xlUp).Row).EntireRow.Delete Shift:=xlUp nSheet = Sheet10.Range("A1:AC" & nList.Count).Offset(Sheet10.Range("A" & Sheet10.UsedRange.Rows.Count).End(xlUp).Row).Value For i = nList.Count To 1 For j = 1 To 29 nSheet(i, j) = nList(i)(1, j) Next j Next i Sheet10.Range("A1:AC" & nList.Count).Offset(Sheet10.Range("A" & Sheet10.UsedRange.Rows.Count).End(xlUp).Row) = nSheet Set nList = Nothing: Set oList = Nothing:Set oSheet = Nothing: Set nSheet = Nothing End Sub