VBA Code To Copy Selected Multiple Columns To Multiple Rows In Excel

Mar 13, 2014

I want to to copy selected columns of sales data into rows organized by salesperson. I have just started out with VBA and find that I cannot do it myself.

My original data are in the form of the following:

invoice_no
product
sales
qty
total

[Code] .....

I want to display the data in another sheet in the following format:

sales_a
sales_b
sales_c
sales_d

[Code] ...........

View 2 Replies


ADVERTISEMENT

Excel 2010 :: VBA Code For Inserting Text In All Column B-cells Of Multiple Selected Rows

Jul 11, 2012

Software: Excel 2010, Windows 7

What is the VBA code for inserting text in all column B-cells of multiple selected rows?

I am creating a worksheet with a table containing various data related to orders of various materials (this is more or less data gathering from an older, paper-based 'system'). This table spans, columnwise, from A to D and expands downwards as more orders are added. The information in each column is: A=order number, B=type of material and C=material specs. and D=additional comments.

I've set it up so that the only thing I really have to do is to insert the type of material in the cells of column B, and the rest will sort itself out. Instead of having to insert a new row for each new entry and manually typing in the name of the material (these entries are often done in the midst of already existing data), I created several similar, macroed buttons for the different types of materials we use. These macros work by selecting the row of the currently active cell, inserting a new row and then add the name of the material in the column B-cell of this new row. What I am having trouble doing though, is to get the text-entry to work for a selection of multiple cells.

As an example, lets say that I would like to add 5 orders of "Grade A Steel" in the middle of the table - in the row above row 8. With the macro I currently have I can select cell B5, click the macro, and a new row will be inserted with "Grade A Steel" in column B of this new row. This action could be performed 5 times over, but would be easier if I could just mark a range of 5 cells, say B8:B12, click the macro and get the text/data inserted the column B-cells of all 5 of the new rows. So far I've been able to create a macro that inserts multiple new rows, but I've only been successful in filling the column B-cell in the first row leaving the 4 below empty.

View 8 Replies View Related

Excel 2010 :: VBA Code To Search Multiple Columns And Delete Any Duplicate Cells (not Rows)

Jun 12, 2014

My Excel program (Excel 2010) currently has several columns and each column looks for and pulls data from a specific file on my computer. Then I need to delete any duplicate data entries, count the number of unique entries and track the changes through a chart. I have everything done except I cannot figure out (or find on the internet) a way to search in multiple columns (more than 2) and delete just the duplicate cells. I want to delete the cells in a way where there is one left. For example if the code 12gf is duplicated three time, I want to be left with one 12gf (it doesnt matter what column the original one is left in). Additionally, column length changes and they are not sorted. I have attempted to attach an image of an example file below.

View 14 Replies View Related

Copy Rows Meeting Multiple Criteria On Multiple Columns

Dec 18, 2006

1. Copy data from original file (I do not want to do anything in the original file) into the spreadsheet (Target worksheet)where the code should run.
2. In sheet 1 of Target Worksheet, there are 2 columns which I need to set criterias on namely Column D and Column L
3. In Column D, I want to specify 3 criterias namely A, B and C
4. In Column L, I want to specify 5 criterias namely London, Frankfurt, New York, Sydney and Tokyo
5. If Criterias in 3 and 4 are met, copy all rows into Sheet 2 of Target Worksheet

View 9 Replies View Related

Copy Multiple Columns From Multiple Excel Files & Paste Into 1 Workbook

Nov 7, 2009

I have 8 different files all have a set of data in them

each one has a long list of (column a-n) however the number of rows change by date. I need each file copied into the finalfile.xls one after another. in the files that will be merged into the final file the final row i need copied is blank.
I have all the copy formulas and everything set, I just need a range to copy that automaticaly takes cell a10 to the first blank a cell from each file and pastes it in the finalfile.xls under the last paste so they dont over write each other.

View 9 Replies View Related

Copy Selected Data From Multiple Rows Into Separate Column In One New Row

Dec 1, 2013

ID Name QTY Price

1 John 5 15
2 Jim 6 20
3 Sue 10 200
4 Fred 12 125
1 Tim 7 26
4 Sue 10 100

I need macro to loop through all data and generate this table in another worksheet

1 John 5 15 Tim 7 26
2 Jim 6 20
3 Sue 10 200
4 Fred 12 125 Sue 10 100

Each data in a row in the new table will occupy a different cell.

View 3 Replies View Related

Excel 2010 :: Converting Multiple Columns Into Rows?

Aug 24, 2012

I am trying to convert

Excel 2010
A
B
C
D

[Code].....

View 9 Replies View Related

Multiple Ccolums/rows To Get Data From Multiple Columns/rows (vlookup)

Jan 15, 2010

I have created a spreadsheet to show some reports and I wanted to serch for some datas which overloops themeselves. If you can have a look at a test file I attached you will see the full picture. I have 2 tables, where the 2nd one is on the right side of the 1st one. 1st table:..............

View 3 Replies View Related

Excel 2010 :: Count Consecutive Numbers Over Multiple Columns / Rows

May 27, 2014

I'm using Excel 2010 and my spreadsheet contains numbers in columns A:E and approx 500+ rows. Here is a 10 row example of my data:

A B C D E
0 1 2 3 4
5 6 7 8 9
0 2 4 6 8
1 3 5 7 9
1 2 4 5 8
3 4 5 6 9
9 8 1 2 3
7 6 1 4 0
0 8 2 1 9
1 0 5 3 2

I would like to count the number of consecutive times each number appears (to a max of 9 consecutive times in a row). So, from my example above:

Number 1 appears:
1 consecutive time = 1 (appears in row 1)
2 consecutive times = 1 (appears in rows 4 & 5)
3 consecutive times = 0
4 consecutive times = 1 (appears in rows 7, 8, 9 & 10)

Number 2 appears:
1 consecutive time = 4 (appears in row 1, row 3, row 5 & row 7)
2 consecutive times = 1 (appears in rows 9 & 10)
3 consecutive times = 0
4 consecutive times = 0

Number 5 appears:
1 consecutive time = 2 (appears in row 2 & row 10)
2 consecutive times = 0
3 consecutive times = 1 (appears in rows 4, 5 & 6)
4 consecutive times = 0

and so on....

View 9 Replies View Related

Excel 2010 :: Convert Multiple Columns To Rows Depending On Input Value

Jul 6, 2014

I have lot of data in Excel 2010 which I wish to bring in Columns using a Macro depending on the input value which the macro should prompt me. For E.g.:

A1B1C1D1E1F1G1H1I1J1
12345678910
12345678910
12345678910
12345678910
12345678910

If I select data from A1 and J1 (in practical it will be more Columns) the Macro should prompt me how many Columns would be the output on Master Sheet. If the input is 2 then it should create an output Sheet "Master" and should show the following result

A1B1
12
12
12
12
12
34
34
34
34
34
56
56
56
56
56
.. ..
.. ..

It after selection I run the macro and input 3 then the output should go in three columns (A1,B1,C1) one below other. If 4 is Input then 4 Columns (A1,B1,C1,D1) will come below each other so on and so forth.

View 6 Replies View Related

Copy Multiple Columns In Multiple Workbooks Into Separate Worksheet?

Feb 27, 2014

The following code won't let me copy from the first workbook. I get a run time 1004 error stating "That command cannot be used on multiple selections".

I would rather not have to copy this by column for each of the 4 workbooks

[Code].....

View 6 Replies View Related

Delete Multiple Rows :: Match In Multiple Columns

Oct 29, 2008

I need to find all rows that have columns that match in all 3 of the columns.

I then need to delete all but the last row in each "group" of rows.

like:

1 q w e
2 q w r
3 q w r
4 q w r

Delete rows 2+3

View 9 Replies View Related

Function/formula To Copy/past Multiple Data Rows In Excel Worksheet

May 19, 2009

I am trying to find a way to copy and paste multiple non concurrent rows of data from one spreadsheet to another.

Ex: I have a large worksheet with approx 20,000 rows of data. I need to copy
and paste every 100th row to a new worksheet.

I think this might be possible by setting up a formula and linking worksheets,
but I'm not exactly sure how to do it.

View 12 Replies View Related

Excel 2010 :: Multiple Entries In One Cell That Need To Be Spread Across Multiple Rows

Jun 17, 2014

I need to convert data from column IDS into separate rows, all other columns need to stay in tact. There are several distinct patterns for the IDS column, main identifiers are always starting with FILER or TEAL and the trailing numbers behind it have no more than 6 digits.

BEFORE MACRO

ID
AREA
TYPE
CLASS
QTY
IDS

1
COAL
TYPE9917312
CLASS881345
2
FILER756911**/**FILER123188 ^** FILER877119*118

[Code] ........

AFTER MACRO

ID
AREA
TYPE
CLASS
QTY
IDS

1
COAL
TYPE9917312
CLASS881345
2
FILER756911

[Code] ......

What the MACRO would look like? This is for Excel 2010.

View 3 Replies View Related

Change Multiple Columns Into Multiple Rows

Oct 10, 2008

I have a large spreadsheet that contains and employee number and then up to 5 entries of Dependants (each has its own column). What I need to do is have 1 for each of the dependant information instead of 5 and have multiple rows for the employee if they have more than one dependant.

At the moment I am sorting the data by dep 1 name, pasting the data into a new sheet, deleting all the dep 1 stuff, sorting by dep name 2 and pasting that.........etc.

It doesn’t take too long to do but I just wondered if there might be a quicker way as this will be something I will need to do more often.

View 2 Replies View Related

Sum Multiple Criteria In Multiple Columns And Rows

Jul 10, 2013

create a formula,for multiple criteria with multiple results in rows.

[URL]

View 1 Replies View Related

Macro To Act Differently On Selected Multiple Columns?

Jan 18, 2014

I have data spread over several columns and this data is added from different files which has a different format than the one required to be in the Consolidated File.

I get results from a portal for Insurance certification, which has Exam Date, Issue Date and Validity Date which is copied manually and pasted from this file and to my master consolidated sheet...then I have to fetch other details for these certified employees from the HR Database which has the data in different formats...

So have to manually copy the format from the previous rows and then copy to the copied data, since this is done more than once in a day its tedious and time consuming so can this be done with a Macro..

I made my own small code but dont know how to make it act differently on selected columns....

I would select the entire matrix and then want the macro to run differently, taking into consideration the column names

[Code].....

I also need to add a vlookup formula for some column based on the column B's value...

Ex: This is for Col C

[Code] .....

So how do I write the code in such a way that the code acts on its own differently.

View 14 Replies View Related

Excel 2007 :: Copy Multiple Unique Values To Multiple Worksheets

Aug 26, 2013

I have an Excel Spreadsheet (2007) that contains over 500,000 records that shows Electric meter usage per month over a 24 month period per meter. What I want to be able to do is to select a meter row per number and copy is to it's own worksheet. At the end - I want to be able to have a seperate worksheet per electric meter number - that I can create a graph. If I go through all 9000 meters and copy and paste into a different worksheet - it will take me weeks to do manually. How can I do this automatically?

View 1 Replies View Related

How To Convert Selected Multiple Lines Of VBA Code Into Comment Line

Jan 29, 2014

Adding ' in the beginning of a line converts the rest into comment line. I wonder if there is an easy way to convert a huge area into comment line to try something on code. I couldn't find such an option in the menu.

View 2 Replies View Related

Adding Sort Filters To Multiple Selected Columns

Nov 14, 2009

I have a row of sub-headings at row 12 that require Sort Filters. My problem is that I need the filters on selected columns only. It seems that with the standard filter button I get all or nothing.

View 8 Replies View Related

VBA Excel To Transpose Multiple Rows And Multiple Column?

Jul 3, 2013

I was planning to transpose this sample data into the output designated below.

Original sample: (There is an empty row after every 4 entries)

Name: xxx
Email: xxx
Phone Number: xxx
Address: xxx

[Code].....

View 9 Replies View Related

Print Selected & Multiple Rows To A Form

Jul 12, 2008

The file consists of 3 sheets:Orders,Order Form PO1 & Purchase Order. When I mark "x" in the row that I want to print, Order Form PO1 will be displayed with all data in the specific columns. However, it only allows me to select one row at a time. Now, I want to select multiple rows so that it will pass the data to the sheet Purchase Order.

View 13 Replies View Related

Keeping Only Selected Rows Over Multiple Worksheets

Nov 29, 2013

I have an excel file with over 20 worksheets and each of them have around 1200 rows. The first column in each worksheet contains the variable names and then the data associated to it is present horizontally.

I only want to keep around 80 rows from those 1200 rows. They are not in sequence (means they are not in continuous order) so I manually selected those rows by deleting the non required rows step by step.

I did it manually on 2 worksheets but I don't want to do that manually over 20 worksheets. Is there any method that can speedup the whole process.

I am attaching the snapshots of the worksheets..

This one is before I deleted the unwanted rows.

This one is after the deletion of unwanted rows.

View 3 Replies View Related

Loop Down Rows On Multiple Selected Cells

Sep 25, 2008

I have a sub that will join the text together from multiple columns into one cell but it only works for one row. I would like it to work through the rows selected. How do I do this?

Sub JoinText()

myCol = Selection.Columns.Count
For i = 1 To myCol
ActiveCell = ActiveCell.Offset(0, 0) & ActiveCell.Offset(0, i)
ActiveCell.Offset(0, i) = ""
Next i

End Sub

View 9 Replies View Related

Merge Selected Rows From Multiple Sheets Into One Sheet

Jul 14, 2009

I have around 150 excel files with sample data as follows in "sheet 1" of each workbook,

Excel doc 1:

ABC1
Column 1Column 221Data 1Data 132Data 2

Excel doc 2:

ABC1

Column 1Column 223Data 3Data 334Data 4

I want the rows with data in column 'B' and empty column 'C' from every sheet to be copied into 1 sheet.

Output to be as,

Final Excel doc:

ABC1

Column 1Column 222Data 2
34Data 4

I have a VBA code sample to select the required files in a folder and run the macro over it. The VBA is as follows,

Sub Importxlsrows()
'Import all selected rows to one sheet
Dim xlsDoc As Object
Dim xlsFileName As Variant
Dim RowNo As Integer 'row number in excel
Dim iRow As Long 'row index in Excel


'probably here we need to insert the required logic

End With
Set xlsDoc = Nothing
End If
Next i
ShowStatusFree
MsgBox "Required rows of selected files are imported into the sheet", vbInformation, "Done!"

End Sub

View 9 Replies View Related

Multiple Columns To Multiple Rows

Jan 14, 2010

I have a spreadsheet that has ONE row for each day of the year and FOUR columns for each day. Some days use 1, 2, 3 or 4 columns. I need to turn these into rows for each Column.

Here is an example of the detail data: ....

View 9 Replies View Related

Excel 2010 :: VBA - Convert Selected Ranges In Multiple Sheets Into One PDF

Feb 10, 2014

I'm using Excel 2010 and would like to know if it's possible to convert selected ranges in multiple sheets into one PDF file? For example, I want to select range("A1:O10) in Sheet1 and range("A1:N25") in Sheet2, then convert both Excel sheets into PDF file with two pages.

View 2 Replies View Related

VBA - Displaying Values In Multiple Lines If Multiple Checkbox's Are Selected

Sep 10, 2012

In my userform I have a list of check box's that can be selected. Currently if more than one is selected, they will appear in the spread sheet in the same line one after another with a space between them. How do I make it so they either appear with a comma appearing after each, so the next value appears on the next line below or most perferably the cell turning to a drop down list with the values?

Current code

VB:
If CheckBox1.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox1.Caption
If CheckBox2.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox2.Caption
If CheckBox3.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox3.Caption
If CheckBox4.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox4.Caption
If CheckBox5.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox5.Caption
If CheckBox6.Value = True Then ws.Cells(iRow, 2).Value = ws.Cells(iRow, 2).Value & " " & CheckBox6.Caption

Spreadsheet current cell appearence if all 6 are selected ' Chinnook EH101 Lynx Puma Sea King Fixed Wing'

Required appearence:
Chinnook
EH101
Lynx
Puma
Sea King
Fixed Wing

View 1 Replies View Related

Copy Selected Rows & Insert As Many Times As Rows Selected

Feb 6, 2008

The following code inserts a row below the selected row, and copies the formula of the row above into it.

Dim Rw As Integer
Rw = ActiveCell.Row
Selection.Insert Shift:=xlDown
Rows("" & Rw - 1 & ":" & Rw - 1 & "").Copy
Rows("" & Rw & ":" & Rw & "").Paste

However, I need to alter this to work for inserting more than one row at a time. ie. the user selects 'x' number of rows and 'x' rows are inserted below (in the same way 'Insert Row' works in Excel) and the row above the selection is copied down.

View 2 Replies View Related

Track Changes On Multiple Selected Ranges On Multiple Sheets

Jul 6, 2007

I need to be able to track changes on selected ranges on multiple sheets, but Excel does not appear to be able to do this. It only appears to allow me to select multiple ranges on the same sheet.

is there a way to track changes on multiple selected ranges on multiple sheets

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved