Concatenation Macro For Variable Rows And Columns?

Apr 12, 2012

Our company gets excel spreedsheets with UPC numbers. The numbers are divided in parts or columns. Sometimes it's in 2 columns; sometimes in 3; and sometimes in 4 like this:

A_____B_____C____D
023__14444__779__9
023__14442__789__7

I'd like to be able to concatenate the digits and have the entire UPC number appear in a blank column to the immediate right and go straight down the line and calculate them all. I figured out how to do this with separate macros for 2, 3, and 4 digits or columns.

Sub Combine_2_Part_UPC()
Do While ActiveCell ""
ActiveCell.Offset(0, 1).FormulaR1C1 = ActiveCell.Offset(0, -1) & ActiveCell.Offset(0, 0)
ActiveCell.Offset(1, 0).Select
Loop
End Sub

Is there a way I could do this with just one macro, by maybe selecting the digits of the first UPC number in the first row of the data to cue the macro in as to how many columns to process?

(The UPCs are in the midst of a lol of other data like product cost, so a macro probably wouldn't be able to figure out how many to calculate on its own.)

View 2 Replies


ADVERTISEMENT

Combining Columns To Create New Rows Not Concatenation

May 22, 2014

RCA Page for forum.xlsx

I'm trying to get entries from one table to appear in another. The first table is like this:

DateDate
Customer Column1
Description Column1
Customer Column2
Customer Description2
Created By

The table I want to put the data into looks like this:
Date
Customer
Description
Created By

View 2 Replies View Related

Store Value In Variable After Concatenation Of Two Values And Putting Into Same Cell

Dec 16, 2011

How to store a value in variable after concatenation of two values and putting it into the same cell.

Let assume, in cell A1, we have value 1 (numeric). And in code i have a variable with stored value as "%".

Now i want to concatenate 1 and % and put it back into cell A1 as 1%.

I have a written a code, but seems to be wrong one.

Sub Percentage()
Per = "%"
lr = Sheets("Process Overview").Cells(Rows.Count, 3).End(xlUp).Row
For i = 10 To Sheets("Process Overview").Cells(Rows.Count, 3).End(xlUp).Row
If Cells(i, 4).Value = "p" Then

[Code] ........

View 3 Replies View Related

Add Concatenation Of Two Columns To Pivot Table?

Jul 18, 2013

I have a large data set that I want to pivot on to produce various results. I can easily pivot on two columns to produce those Unique IDs where East AND West are "Yes" or "No." I want an easy to filter on results where either East OR West is "yes." I could do this with a joined (Concatenated column) such as East/West but was hoping there might be an easier solution built into Excel pivot feature.

Unique ID
East
West

1
Yes
No

2
Yes
Yes

3
No
Yes

4
Yes
No

5
No
No

View 2 Replies View Related

Merge Rows Into Columns With More Than One Variable

Nov 12, 2007

I have been scanning web forums for days and have not found a solution to my question. I have found similar, but unfortunately am not clever enough with Excel VBA to adapt.

I have two columns of data which I want merged into rows (a) by survey number and (b) by time slots. The data I have is similar to:

Survey No.....Results
12345...........9am-12pm
12345...........3pm-6pm
12345...........No answer
56789...........6am-9am
56789...........12pm-3pm
56789...........6pm-8pm
56789...........10pm-12am
.....................

View 12 Replies View Related

Paste Automation With Variable Columns And Rows?

Feb 25, 2013

I'm trying to come up with code that will allow me to take numbers arrayed as follows:

25
25
42
42

[Code]....

The number of rows and columns are both variable.

View 3 Replies View Related

VB - Transpose Variable Number Of Columns Into Inserted Rows

Jul 23, 2012

I have a sheet with a company name in column A, and a list of comma separated values in column B. I can easily convert column B to multiple columns with the Text to Columns function, but then I'd like to insert each individual value in a new row in column B.

So, at the moment I have data that looks like this:

Company A
Value 1, Value 2, Value 3, Value 4, Value 5

Company B

Company C
Value 1, Value 2, Value 3

[Code].....

View 6 Replies View Related

Macro To Sum Variable Length Columns?

Jul 26, 2013

how can I make this simple macro sum columns that will be of variable length? I would like the sum to appear as the last entry in that column and highlighted.

VB:
Range("H36").Select
Selection.FormulaR1C1 = "=SUM(R[-34]C:R[-1]C)"
Range("J36").Select [code]....

View 7 Replies View Related

Macro To Create Columns By Referencing A Variable Column

Jul 11, 2014

I've only done a small amount of macros with VBA.

I want to create a macro to insert 12 cells left of a column labeled "This Year" As the spreadsheet grows (by 12 columns @ year) the "This Year" column moves to the right. Thus I need to reference the range off of that column and then insert 12 columns directly to the left of it each year. Can I somehow reference the label "This Year"?

I then need to enter the month labels in the new columns row 8.

My problem is trying to reference off the "This Year" column.

View 8 Replies View Related

Variable Number Of Rows In Macro

Nov 2, 2011

I'm trying to write a macro with a variable number or rows depending on the total number of rows the workbook has.

I tried like this:

Code:
Sub provaanova()
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range(("$J$2:$J$") & Range("J" & Rows.Count).End(xlUp).Row) _
, ActiveSheet.Range(("$J$2:$J$") & Range("J" & Rows.Count).End(xlUp).Row), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub

and:

Code:

Sub Provaregress()
r = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$r") _
, ActiveSheet.Range("$K$2:$M$r"), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub

But it gives me an error. The only way i was able to do it without error was:

Code:
Sub Provaregress()
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$53968") _
, ActiveSheet.Range("$K$2:$M$53968"), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub

But as u can see it has a fixed number of rows. ( I need variable number of rows detected on column J, and then run regression with K,L,M as depending variables).

View 5 Replies View Related

Macro To Delete Variable Rows

Jan 4, 2012

I am creating a macro to tidy up a large data sheet. it is a list of products as follows:

Heading1Code; Heading2date; etc
12
12
12

13
13

14

15
15
15

The blanks beneath each series of products need to be deleted but they are variable and a macro that i write is not flexible enough to remove a variable number of blank rows beneath a variable number of each product.

View 9 Replies View Related

Printing Variable Rows With A Macro

Feb 14, 2007

I export data from another programme into excel and have written a macro to move and format this. The number of rows of data exported will be different each time. I need to be able to print this data and want to add it to the macro. I have learnt to use this code to select this data working from the last used cell to the top

Range("a1:d1", Range("a65536:d65536").End(xlUp)).Select

Using the macro recorder for printing one of my exports I got this code

Range("A1:D53").Select
Range("D53").Activate
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup.......................

View 5 Replies View Related

Macro To Concatenate Variable Amount Of Columns Based On Cell Value

Jul 23, 2014

I have a table that looks like:

7300
3

7301
2

7302
5

And I am trying to make a macro that will go concatenate the first 3 columns of all rows in worksheet 7300, the first two columns of all rows in worksheets 7301, etc, and insert them into column A of each corresponding worksheet.

View 7 Replies View Related

Macro To Copy And Paste Into Another Sheet At Variable Rows?

Nov 14, 2012

Sheet 2 has 3 cells with values:

C14, C15, C16

I need VB code to:

copy the values in those cells

Return to Sheet 1, let the user click a cell in any row in Colum F, then Paste them (Special, Values and Transpose)

View 4 Replies View Related

Copy And Paste Macro - Variable Number Of Rows

Jan 13, 2009

I am working on a macro where I am creating a formula to string together some text columns and then copy the formula down the entire column. The data source I will be performing this on will change in number of rows period to period. The data would be in columns A,B & C and the formula is in D. The formula in D is stringing together the data in AB & C and then I want to copy and paste that formula down to the bottom of all of the data. What would the code be for the copy and paste with variable rows?

View 9 Replies View Related

Getting Rows To Columns Macro Skipping Blank Rows

Dec 28, 2011

I have this in Column A, with about 120 entries:

Company 1
Contact 1
Address 1
City, ST, ZIP 1
Phone 1
Fax 1

Company 2
Contact 2
Address 2
City, ST, ZIP 2
Phone 2
Fax 2

Company 3
Contact 3
Address 3
City, ST, ZIP 3
Phone 3
Fax 3

I want this:

Company 1 Address 1 City, ST, ZIP 1 Phone 1 Fax 1
Company 2 Address 2 City, ST, ZIP 2 Phone 2 Fax 2
Company 3 Address 3 City, ST, ZIP 3 Phone 3 Fax 3

all the way down.

I can't figure out how to record the macro to tell it to then skip the blank line, collect the next set of data, and put it in the next row. I can do it for two, but then it just replaces the first two with the next two and I lose data.

View 5 Replies View Related

Macro Code To Add Sum Formula/Function, With Variable Rows, To Cell

May 29, 2008

I am having to copy and paste rows of data into a new worksheet where the rows sizes change and I am wanting to add a new row at the end of the pasted rows but with the sumation formula to add the relevant column

e.g copy range B14:AA17 with in this case columns E to AA holding the numerical values. Therefore I wish in cell E18 to sum the value of E14:E17 and so on ending with cell AA18 holding the sum of AA14:AA17

As these vary I have all relevant variables, Range to add sumation values to eg E18:AA18
Start Cell E14 and so on.

I tried adding "=SUM(x:d)" where x and d are vars relating the the column cell required eg x = E14 and d = E17

View 3 Replies View Related

Summing Variable Values Across Variable Sheets In Multiple Columns

Jun 27, 2014

I need a macro that will create a sheet at the end of the workbook.

Sum data from a variable amount of sheets and display that data on the created sheet.

Here is a step by step:

Starting on sheet 5.

Column D has a variable amount of part numbers in it. These part numbers would be different between the ascending sheets.

Column T, U, V has an inputed number in it that would need added up across all duplicate part numbers in all the sheets.

(Note: The data would also need started on row 4. Everything above row 4 is headers)

Here is a small example:

D E T U V
13019090W Part A1
68705500 Part B1
64202900 Part C-11
59634600 Part D1
26005300W Part E1

I need the macro to start with sheet #5(starting on row 4). Check to see if there is data in column T, U or V. If there is, to create a new sheet at the end. And copy the entire line into that sheet (starting on row 4).

After that, to check every sheet after (excluding the newly created one, starting on row 4) for data in Column T, U and V. And then check for duplicates in Column D on the newly created sheet. If there is a duplicate to add/subtract that number in Column T, U and V to the SUM in column T, U and V in the newly created sheet. If there is no duplicate, to copy the entire line to the new sheet.

So that when finished. On the new sheet, you have the SUM of T, U and V for everything that has data in T, U or V for all of the previous sheets, plus the entire line of the first instance (excluding the first 4 sheets).

View 2 Replies View Related

Insert A Variable Number Of Rows And Copy And Paste From And To Variable Positions

Aug 8, 2009

On the attached Excel file, I have code that will insert a variable number of rows and copy and paste from and to variable positions. That all works fine when run from a command button, but when I try to run it from the Worksheet_Calculate by entering 1 in J1 or K1 (inrange cell is J1+K1 for testing purposes) the CommandButton1_Click sub runs continously until an error occurs.

View 4 Replies View Related

Moving Rows And Columns With A Macro

Jun 5, 2009

I have a massive data file with thousands of lines of data. Each line is a pair, for example

View 6 Replies View Related

VBA Macro Involving Rows And Columns

Mar 2, 2012

I have have a problem in my vba code

if my activecell is on example range("W78") then it will go to range("I5")

I made a code but it does not work, i cant use offset cause i have may columns but they all refer to the same column "I"

this is my example: Range("I & activecell.row").value

View 4 Replies View Related

Macro To Match Rows In Two Columns

Sep 6, 2007

need a quick macro to match rows in two columns as per demonstartion below.

View 9 Replies View Related

Macro To Change Columns To Rows

Mar 4, 2008

Excell macro to change columns to rows example

From this:
A B C
1 3 5
2 4 6

to this

A 1
B 3
C 5

A 2
B 4
C 6

View 9 Replies View Related

Macro To Hide Rows And Columns

Aug 1, 2008

The macro code that will populate and input box and ask you which range of columns and range of rows you wish to hide, hide the columns and advise you via a message box that it has been completed

View 9 Replies View Related

Macro For Rows And Columns Interchanger

Nov 4, 2008

I saw a macro written in this forum where we can select 256 rows to interchange them to colums in sheet 2. I need my first 10 rows to be in first column and next 20 rows in second column in sheet 2 ,like that it goes on . I am a very basic user of Excel .Can i get a macro with some condition that helps me in the above case.

View 9 Replies View Related

Macro For Copying Cells To Columns And Rows

Sep 22, 2012

Why does my macro mess up on second line C23 and not places Play Equipment or the amount in the right column it stays on row C22

[URL]....

Code:

Private Sub CommandButton1_Click()
Dim SheetName As String
SheetName = "Estimate1"
SheetName = InputBox("enter the name of a sheet to use", "sheet name", SheetName)

[Code]....

View 2 Replies View Related

Macro To Add Rows After Each Change In Values Over Two Columns

Jun 22, 2013

I'm trying to create a macro that will add a blank row each time the values changes in two different columns. I’ve got a macro that sorts the data on two columns, just need to add rows after each change in both columns.

I've found something that'll add rows after each change in one column, the problem is adapting to add rows after each new value in a 2nd column as well.

What I have so far works until it hits the first empty row inserted after sorting by first column.

Sub SplitList()
'
' SplitList Macro
' Macro recorded 05/03/2004 by GaryB
rw = 5
myval = ActiveSheet.Cells(rw, 4).Value

[code].....

Here’s a data sample after performing my sorts, but before the macro to add spaces:

Another, Guy CDP EX 8.36 8.36 0 0 0 0 0
Jones, Some CDP SS 3.3 3.3 0 0 0 0 0
Justa, Nother ESP NV 22.45 22.45 0 0 0 0 0
Person, One ESP SS 23.36 23.36 0 0 0 0 0
Tom, Rich SSP MA 2.35 2.35 0 0 0 0 0
Dude, Steve SSP UN 63.86 25.36 5 1 2 1 1
Blanke, Spaece SSR MA 12.24 12.24 0 0 0 0 0
Try, Again SSR MA 15.25 15.25 0 0 0 0 0

And after the attempt to add rows: (note that it added a blank row between the first and 2nd rows (which differed in the 3rd column), but that it then stopped.

Another, Guy CDP EX 8.36 8.36 0 0 0 0 0
Jones, Some CDP SS 3.3 3.3 0 0 0 0 0
Justa, Nother ESP NV 22.45 22.45 0 0 0 0 0
Person, One ESP SS 23.36 23.36 0 0 0 0 0

[code].....

And, what I’d like it to look like:

Another, Guy CDP EX 8.36 8.36 0 0 0 0 0
Jones, Some CDP SS 3.3 3.3 0 0 0 0 0
Justa, Nother ESP NV 22.45 22.45 0 0 0 0 0
Person, One ESP SS 23.36 23.36 0 0 0 0 0

[code].....

You can see, it seems to be hanging up once it hits a blank row after first round of inserted rows.

View 3 Replies View Related

Hide Rows In VBA Macro By Checking 2 Columns

Oct 8, 2009

I've tried using multiple loops in the forum but cannot seem to figure out how to actually get them to work properly using the conditional VBA codes on two separate worksheets. The first code snippet is checking cell values from row 6 to 148 as such:

Sub Check_Shifts()
'Insure all shift entries are completed
If Range("K6").Value < "1" And Range("I6").Value < "1" And Range("G6").Value < "1" Then
Range("G6").Value = Range("F6").Value
Range("I6").Value = Range("F6").Value
Range("K6").Value = Range("F6").Value
ElseIf Range("K6").Value < "1" And Range("I6").Value < "1" Then
Range("I6").Value = Range("G6").Value
Range("K6").Value = Range("G6").Value
ElseIf Range("K6").Value < "1" Then
Range("K6").Value = Range("I6").Value
End If
If Range("K7").Value < "1" And Range("I7").Value < "1" And Range("G7").Value < "1" Then........................

View 7 Replies View Related

Macro To Fill Cells Of Rows Based On Two Other Columns

May 28, 2014

Data file with few columns. There are groups of similar ID numbers in Column J. For a group of similar ID numbers in consecutive rows there is only one row that has a number greater than 0 in its Column L cell and the rest of the cells of Column L for that set of similar IDs is filled with 0s.

First for that unique ID group I need to find out which row is it that has a value greater than zero in its Column L cell.

Then I need to use that value to fill the rest of the 0s in Column L corresponding to that set of Unique IDs.

The process continues with identifying similar IDs in Column J and this time doing the same thing for their Column M. I have attached a sample file that shows the data and how the results need to look like.

See here Fill Cells.xlsx

View 1 Replies View Related

VBA Macro To Loop Text To Columns Through All Rows Of Data?

Apr 17, 2014

I am trying to get a macro to run in excel that takes a simple text to columns command in one line of data and runs the command on a loop through however many rows of data there happen to be.

I've attached two screenshots - one with what I've got now (Before.jpg) and what I'd like to have after the macro runs (After.jpg). The code below is what I used to get the first text to column breakout, which I can hopefully run on a loop to breakout anything in the DEPT column that contains a "/". It can ignore the rows that only have one department to begin with.

Selection.TextToColumns Destination:=Range("K2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="/", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True

Eventually I'll want to create another macro that transposes the breakout text back into the DEPT column and populates it with the corresponding data, but I figure I'll take things one step at a time.

Attached Images
Before.jpg‎
ter.jpg‎

View 10 Replies View Related







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