![]() |
Copy and Paste Function
I need some VBA code to search the contents of column AI for certain text,
then if found copy that row's range T:AH and paste it elsewhere. For instance if "3" is found in T it will need to be pasted into AI:AW. If "4" is found in T then the same range (T:AH) will need to be pasted into AL:AZ. And so on... I know this is easy, but having a hard time getting it to work. Thanks! Chris |
Copy and Paste Function
Can you expand on the rules governing how this is supposed to work? Is the
"text" you are looking for always going to be a number as your two examples show, or will other text be involved? What governs the the range T:AH is to be copied to (your example has two consecutive values being found in the same column, but getting mapped ranges that are not consecutively offset from AI)? Remember, we do not know anything about your set up and what you want to do with it unless you tell us. -- Rick (MVP - Excel) "Outatym" wrote in message ... I need some VBA code to search the contents of column AI for certain text, then if found copy that row's range T:AH and paste it elsewhere. For instance if "3" is found in T it will need to be pasted into AI:AW. If "4" is found in T then the same range (T:AH) will need to be pasted into AL:AZ. And so on... I know this is easy, but having a hard time getting it to work. Thanks! Chris |
Copy and Paste Function
Sorry about not being more descriptive, I didn't want to over load it with
details. Scratch what I said before... The spread sheet contains voting data within a county. Basically, column T will have a numerical value (3, 4, 6, 7, 8, 9) representing a constituients first voting year (2003, 2004, 2006...etc). Column U is their vote in the Primary of their first voting year and V is their vote in the General election of that year. Column W has individual's second voting year. Column X is that year's primary and Y is the general. And so on for 5 years worth. The problem is that running a query on this data is not going to work the way it is, so I will need to sort and move some of the data. I have created new columns for the voting information that will work better for the database I'm creating. The new columns are "2003 voting year", "03 Primary", "03 General", "2004 voting year", "04 Primary", "04 General", etc.... I will need the code to search column T for the year (i.e. 3, 4,5....) if it is 3 then it will need to move all of the voting info (range T:AH) to the new column for 2003 voting year, then pasted so the data will fill up to 2008(AI:AW). If the there is a 4 in the T column it will need to move the data (T:AH) to (AL:AZ). Hope this clears it up some. I know what I'm needing to do, yet am a little fuzzy on the code to find text, copy a selected range, and to paste it where it's supposed to go. Thanks for the help! "Rick Rothstein" wrote: Can you expand on the rules governing how this is supposed to work? Is the "text" you are looking for always going to be a number as your two examples show, or will other text be involved? What governs the the range T:AH is to be copied to (your example has two consecutive values being found in the same column, but getting mapped ranges that are not consecutively offset from AI)? Remember, we do not know anything about your set up and what you want to do with it unless you tell us. -- Rick (MVP - Excel) "Outatym" wrote in message ... I need some VBA code to search the contents of column AI for certain text, then if found copy that row's range T:AH and paste it elsewhere. For instance if "3" is found in T it will need to be pasted into AI:AW. If "4" is found in T then the same range (T:AH) will need to be pasted into AL:AZ. And so on... I know this is easy, but having a hard time getting it to work. Thanks! Chris . |
All times are GMT +1. The time now is 03:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com