How To Move Data In Various Cells To New Columns Based On Search On Primary Column
Feb 4, 2014
I have a sheet which I need to arrange and it looks like -
the values in Column B, C , D , E & F need to be in new columns based on what we have in Column A associated with "1"
Output should be -
so whatever is in Column A associated with "0" should remain in place whereas whatever is in Colimn A associated with "1" should get added to the new columns. 0 and 1 resembles the 1 Records which are used as a split to normalize the data.
The following code works to update the target sheet based on matching column names within the source sheet.
However, I would like to bolster this by not only updating based on matching field names, but also the primary key in column A. Meaning the data from the source sheet isn't always in the same order (based on primary keys) as the data in the target sheet. So I want to keep the order of the primary key in the first column and then update matching field names in column B through the last column where the primary keys match between the source and target worksheets.
Sub CopyDataBlocks() 'VARIABLE NAME 'DEFINITION Dim SourceSheet As Worksheet 'The data to be copied is here
Column A | Column B | Column C Los Angeles | Fire Dept | 3 Los Angeles | Health Services | 12 New York | Fire Dept | 8 New York | Health Services | 22 New York | Internal Services | 100 New York | Public Works | 7 Chicago | Health Services | 15 Chicago | Public Works | 56 Chicago | Social Services | 4
And I am trying to make it look like this:
Fire Dept Health Services Internal Services Public Works Social Services
i think this will be simple for most of you. i need a macro that will move blocks of cells from one column into the succeding columns. say i have one column of 1000 values and i need to break that up into columns of 50.
I am trying to move information that is pulled from a database to look cleaner and easier to read. All of the information exports out into column A only. The attachment is a brief example of what it looks like, and what Iím trying to get it to look like.
I want to move the data in col A to 5 columns C through G in groups of 16 rows. Once the last column is filled with a group of 16, it needs to fill below the first group of 16 in column B onward to column F. It should repeat this process until there is no more data in A. The attachment shows it much better than i can explain it.
I have some basic experience with formulas and macros, but I havenít had any luck trying to manipulate any of them to give me the information the way I have shown. I would prefer to not have to manually type or cut and past the information in if possible.
I have a table with one column of data. The data in this column repeats with 4 relevant pieces of information that I want to put in 4 different columns (fields) in a different spread sheet (or the same would work better and I would just delete the first column when done) keeping the same order the data is now in. The data currently repeats in a regular pattern (i.e. 123412341234 with no other data in between). I would like to do this with a macro. Could someone help write a macro that will do this
I saw this thread from June Cut & Paste Macro: Move Address From Column To Row and I think this what I would like to have my macro do. I have one column which is copied and pasted as text in excel and there is several blank rows.
I attached the spreadsheet example - it has 40 lenders, with the top row being the lender name (A1), followed by address(A2), city-state (A3), two blank rows(A4-A5), lender type (A6), approved date (A7), one blank row (A8), lender specialty (A9), telephone (A10) , e-mail address(A11) and two blanks rows (A12-A13) and A14 starts over again. For this example there should be 8 columns and 40 rows (lender name, address, etc...). As I mentioned I think the previous thread's macro would work with some minor tweaks. I couldn't figure out the best way to handle the blank rows and or remove the blanks and what to add or take out of the macro code.
I am in need of restructuring a spreadsheet of addresses for mailing purposes. (I tried to find something similar answered previously, but nothing seemed to work for me.)
I have attached a small example spreadsheet below, but our spreadsheets can be hundreds or thousands of rows in length.
I need a macro that will look for the "PO Box" addresses under the column headers named "ADDRESS2" and "ADDRESS3".
The PO Box addresses will need to be moved under the column header "ADDRESS1" within the same row.
It will need to overwrite the text that is already under "ADDRESS1" and delete the text from the "ADDRESS2" and "ADDRESS3" columns - UNLESS the text in 'ADDRESS2" is a PO Box AND "ADDRESS1" begins with "c/o".
If the data in "ADDRESS2" or "ADDRESS3" is anything other than a PO Box it will remain the same. As will "ADDRESS 1".
Basically if there is a PO Box it needs to be in the column named "ADDRESS1" and overwrite anything else that was there. The exception will be for PO Boxes that are in c/o someone else, the PO Box will then need to be listed in the column directly after the column that has c/o.
If the c/o exception will be too difficult the code could just highlight those scenarios and we could fix them manually. We usually do not have a lot of them, but enough that we need to be mindful of them.
The different scenarios are listed in my sample spreadsheet.Also, the code will have to use the column header names in row 1 because those headers are not always in the same column.
I am trying to move a column of numbers based on the information in another column. I've been looking for about a week and find macros that are close but not quite.
In one column it reads Mobile, Home, or is blank. If the number is a Mobile (column R), the area code (column P) needs to move to column S and the phone (column Q) needs to move to column T and the primary phone (column R) needs to move to column U. Home and blank cells remain as they are.
area (P) phone (Q) primary phone (R) col S col T col U
There is a spreadsheet that I use that has multiple plans in one column for various members. You can see the plan for Robert James and Amanda James is plan 5. If all this information was in column A how would you move the plan type say column C for each member?
For example Column A Customer Name Robert James Amanda James Plan 5 Nikki Martinez James Gross Plan 6
I have some macros that will look for a certain item and then move it somewhere else on the spreadsheet. However, I can't seem to get the code right to skip over the section if the text is not found. I assume it would be easiest to do it with error handling, but the attempts I've made haven't worked.
the macro will search for the text "Name" and move everything under that column elsewhere; then it will do the same for "Date." But currently, if "Name" is not found anywhere on the spreadheet, it will cause an error and ask to end or debug.
I have been using a macro to search and highlight customer addresses for me, however I have changed my worksheet and now have the addresses in two columns instead of one (D for the numbers, E for street names) for sorting purposes.
What I would like to do is either; find a way to search using data from 2 cells to get a result, or have multiple results highlight and popup.
Using: Excel 2010
Code: Sub SEARCH_FUNCTION() Set FoundCell = Sheets("Route").Cells.find(What:=Sheets("Intro").Range("G15"), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) If Not FoundCell Is Nothing Then With FoundCell
Sheet 2, Row 1 column B-E contain restraurant names (only on the top row, like field names).. i.e. I manually put the date in because typically the projected date is different from the actual review date.
-A----------- B ----------------C ------D-------- E----- Date |Ruby Tuesdays|Olive Garden|TGIF|Ruths Chris|
I need the data from Sheet 1 Column B moved to sheet 2 in the next open row (i currently have data in row 1..the field names and down to row 35). This will be continuous so each time i need it to add the score as a new row in the correct field (restaurant name), IF the restaurant isnt listed, I want a new field named with the restaurant name and then place the score in the correct row and column. So, in the example I'd need Outback added.
I am basically trying to find the first non-empty cell in a range, but I want the macro to look down columns first. In other words, I want it to look down column A, then column B, and so on. Right now I believe it is searching by rows.
With Columns("A1:D15") .Find(what:="*", after:=.Cells(1, 1), LookIn:=xlValues).Activate End With
I have a document to track funding and would like to be able to auto-populate individual task sheets within the workbook based on a task drop-down. So if I choose Safety from the "Task Area" drop down it would auto populate the full row from the Master Sheet to the Safety Sheet. I have uploaded my document so you can better understand.
Basically I'm trying to write a formula that will sum the total of the numbers from column B but only where the month equals June AND column 3 says "Yes".
So the answer would be 101, because rows 2 and 5 are the only rows of that table that meet all the criteria, and the sum of their column B cells would be 101.
I thought I was getting there with Sumproduct and Sumif but I'm now drawing a blank. There is a little extra complexity in that I'm actually pulling the month value from a set of cells elsewhere, but if someone can solve the puzzle above I hope I can do the rest on my own as it's just locations of data to pull from other worksheets really.
I am trying to write a macro that will take data from column A and use it as a column header in column C, and then take the corresponding data in column B and list it under the column header in column C. When the value in column A changes it will move on to column D and then list the corresponding data from column B underneath it in column D until all of the data in the 2 columns is spread across the worksheet. Example:..............
I need help creating a macro that will search through my excel spreadsheet and for every instance where column A isn't empty it should cut a range of columns from that row and paste them in a different range of columns in the row before it. It should then delete the row that it cut the columns from and keep searching until it has done this for the whole worksheet. I can modify which range of columns are needed, but it has been so long since I've worked with excel macros that I haven't been able to do it.
I'm trying to hide columns based on information in another column. If that column contains "A" or "B", hide columns "U" through "W". If it contains "A", "B", "C", or "D", hide columns "V" through "W". Etc, etc., so on and so forth...
I've snipped the code I found earlier and modified it to (what I thought) was correct for my application, but it doesn't seem to do anything. (btw, should I get an error if it doesn't run correctly?)
Here is the code as modified:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "P:P" Then
If LCase(Target.Value) = "A" Or LCase(Target.Value) = "B" Then
Columns("U:W").EntireColumn.Hidden = True
ElseIf LCase(Target.Value) = "A" Or LCase(Target.Value) = "B" Or LCase(Target.Value) = "C" Or LCase(Target.Value) = "D" Then
In the sheet I'm currently working on I have a column (column C) that uses a validation so that users can select from a number of call types (data tracking in a call center). I allowed for an "Other" option, with a free-form column (column D) dedicated to the "other" reason in case the list doesn't cover the type, but I'm running into a problem where people use the other column to describe call types already listed. Is there anyway to lock the Other column (column D) unless Other is selected in the drop down in the Call Type column (column C)? The sheet I'm working with contains confidential data so I can't post it, but if this isn't clear enough I can draw up a mock sheet.
I have 1 sheet called Setup which users enter their character name, their class, and their race, additionally the entire workbook manages data for up to 9 individual characters.
On another sheet called C|R|E, I have tasks listed that are based on each class type and each race type that are available. Currently there are nine classes and four races. Currently on this sheet each class and each race has its own individual data lists and such, and formulas are done in a way that user inputted data can be entered anywhere, but wont count unless the class and race match those selected on the Setup sheet. To keep the sheet short in appearance I used command buttons to hide/unhide classes or races not in use by the user.
What I was wondering is (and this could be hard to describe), can data in one column be changed to reflect data based on another column's focus? I will explain in more detail.
Column B contains the task information for each Class and Race. For example Cells B13-B51 for one class, Burglar. Columns D-L is where users enter data to show if the task is completed or not. In this example lets say the users first character listed on the Setup sheet is a Champion. What I want to do is check the Setup sheet Char 1. Then based on what Char 1 is selected as on the Setup Sheet, C|R|E B13-B51 data is changed to reflect it, IF Column D currently has focus. If Column E gets focus then B13-B51 changes based on the class selected on the setup sheet for character 2. and etc.
If this can be done I can remove the 13 different sections and have it down to 2 sections, one for class, one for race. For now I am using check boxes to hide classes and races they are not currently using, but would like to move all classes into one table and all races into one table to they dont have trouble with columns they have to skip over currently.
This is a sample of how I am currently working on the C|R|E sheet, the full code is much much longer since I am using so many command buttons.
Column A is numbered 1 -100 successively Column B thru D contains data that goes with the assigned number in column A. I need to be able to move rows of data in column B through D to a different set of rows all at the same time (not one cell at a time) without disturbing the set numbers in column A. And with that, have all the other rows of data automatically adjust accordingly(not to be deleted or replaced).
How can you move data from multiple columns into a single column? I have attached a short example of the data I receive. (In reality, the data could be hundreds of columns and/or hundreds of rows, but this is representative of what I might receive). It does not need to be sorted and including the header row in its own column is optional. I do not know VBA all that well but can muddle through it if someone can give me an example of what the code should look like.
I have 2 large rows of data next to each other imported from a different programme. Some of the cells in these 2 rows consist of values, some consist of words. I only want to cut the cells with values in these rows and paste them in a new row, called TXid. I have written VB code that cuts all the data in the rows and pastes them onto the new row. Now I would like to cut only the values in the row. How do I select only the values in the cell?
Cells.Select Cells.EntireColumn.AutoFit Range("I1").Select ActiveCell.FormulaR1C1 = "TXid" Range("G3").Select Do If ActiveCell = IsNumber = True Then Selection.Cut Selection.Offset(0, 2) End If ActiveCell.Offset(1, 0).Select Loop Until ActiveCell = "" Range("H3").Select Do If ActiveCell = Isnumber = True Then Selection.Cut Selection.Offset(0, 1) Loop Until ActiveCell = ""
The ActiveCell = Isnumber = true is not working the way I want it to.