Insert Rows Based On Number Of Columns Used

Jan 31, 2008

I have a spreadsheet which contains data needing to be re-formatted into a suitable format for my database. So far I have been doing this by hand, but want to make it quicker as I have over 2000 lines to sort out. I am trying to write a macro that determines whether there is data in the column next to the active one (D2), and if there is counts how many columns there is data in. Once it has done this it needs to insert the same number of rows as there are columns, then copy the column data and transpose it into the empty rows. My macro seems to work at first, but it exits after around the 4th row, but I can't work out why.

Sub split_For_Database()
Dim No_Of_Cells As Integer
Dim Start_Cell As Range
Dim Cell As Range
Dim LastRow As Range
Dim i As Integer
Dim lRows As Long
Set LastRow = Range("C65536").End(xlUp)
i = 0
Set Start_Cell = Range("C2")
Set Cell = Start_Cell
Do While Start_Cell.Address <= LastRow.Address
Do While Cell.Offset(0, 1) > 0
i = i + 1
Set Cell = Cell.Offset(0, 1)
Loop...................................

View 8 Replies


ADVERTISEMENT

Count Columns With Data Then Insert That Number Of Rows

Feb 11, 2014

Original

01012014 DAVE JOHN
02012014 MAT
03012014 CHRIS MIKE PHIL

What I want

01012014 DAVE
01012014 JOHN
02012014 MAT
03012014 CHRIS
03012014 MIKE
03012014 PHIL

View 4 Replies View Related

Insert One Or Two Rows Based On Two Columns Criteria

Feb 3, 2009

I need to insert one or two rows depending on the criteria of two different columns.
We have two shops (A and B)...and the sales are expresed like this: ....

View 9 Replies View Related

Insert Number Of Rows Based On User Input

Apr 23, 2014

I have an excel sheet that I've automated for my shop ... Basically it copies a set of rows from one sheet, asks for which cell you want to start the paste at, then pastes it... Here's what I have so far:

[Code] .....

So I tried to use a variation of strReturn to indicate number of rows wanted but that didn't work ... Basically I'm going to create the "data" to include 50 rows, but have it selectable for the user to say they only want 5, 7 or 29 rows ...

View 2 Replies View Related

Insert Number Of Rows Based On Cell Values?

Feb 20, 2009

Column B contains geographical Areas. Column C contains a list of business departments.

North Env
North Env
North Ops
North Sales
North Sales
North Sales
South Env
South Maint
South Ops
South Sales
South Sales
South Sales

Etc.

The values and number of these departments will vary. I want to insert lines to sum the totals at the bottom of each geographic area based on the number of different departments. So, for this example, for the North three lines would be inserted. For the South, 4 lines would be inserted.

View 4 Replies View Related

Maro, Insert Rows Where Rows Determined By Number Of Carriage Returns

Feb 17, 2010

The best way to explain my problem is to look at the table below:

How it looks now: ApplePrice 1
Price 2
Price 3FruitDeliciousPearStore 1
Store 2FruitVery DeliciousHow I want it to look:ApplePrice 1FruitDeliciousApplePrice 2FruitDeliciousApplePrice 3FruitDeliciousPearStore 1FruitVery DeliciousPearStore 2FruitVery Delicious

View 9 Replies View Related

Insert Certain Number Of Columns

May 21, 2009

somehow i managed to do this at first and then forgot to save my personal work book and cant remember how to do it.

What it is, is if cell A1 has a certain phrase in it ie Customer Reference then i want to insert four columns before it so it ends up in cell E1.

The other thing which i never managed to do is. I have 5 workbooks. master, book 1-4. I want to past all info in columns A:T from Book 1-4 into Master in the next available row.

View 10 Replies View Related

Macro To Insert New Rows Based On Commas In Previous Rows?

Mar 15, 2014

I'm a macro novice and have been trying to teach myself how to write the correct one for a task I need to do, but I cannot seem to get it right. Basically, I have bunch of data and for one of the variables, different values are separated by commas. What I want is to create a row copying the info below for each piece of data after the comma.

Sheet1

A
B
C
D

[Code].....

I suspect there is a fairly easy way to do this, but I cannot figure it out from searching the forums (or rather, I can't get it to work right).

View 6 Replies View Related

Columns To Insert The 2 Rows

Aug 22, 2007

I have this excel file which has data in it. However, this data will come in everyday. Eg, A1 to A10 is QWE, A11 to A20 is RTY, A21 to 30 is UIO. But as I said earlier new data will come in everyday. For eg, it will become A1 to A15 is QWE, A16 to A30 is RTY and so and so forth.

I need to insert 2 rows after QWE, RTY, UIO. But as data will come in everyday, I cant standardise my columns to insert the 2 rows.

View 14 Replies View Related

Insert Specified Number Of Rows?

Jul 30, 2013

Is there a way to insert a specified number of rows. For example, I want to insert 500 blank rows today but maybe tomorrow it will be 650 blank rows.

View 1 Replies View Related

Insert Formula Across Variable Number Of Columns With VBA

Jun 19, 2014

I have two variables - the number of stages, and the number of people.

The stages will start in say C22 through G22 (if there were 5 stages). The number of stages will vary upon a user-inputted number in A1.

The names of people will start inB29, so I'd like to insert the simple formula (=Max(C23:C28)) across cells C29-G29 (again with my example of 5 stages), with relative references to the columns, of course.

Ditto for the next name in B30, etc, so that I get the max value for Person#1 in Stage 1, 2, 3...Person#2 in Stage 1,2,3...

Inserting the formula over the dynamic ranges.

View 8 Replies View Related

Compare Columns And Insert Rows?

Aug 16, 2012

I have attached an example of what I need the macro for. I really need it to look at the columns with the names (Girth Weld, Weld) and the Joint length column to make its moves. Mainly the joint length. I think that would get me on track and give me some room to explore and learn what else I need to do. I love to try and figure things out but this is killing me!

[URL]

VB:
Sub LineUp() 'assumes data in order and concates unique
Dim i1 As Long, i2 As Long, n1 As Long, n2 As Long
Const StartRow As Long = 5

[Code].....

View 4 Replies View Related

Prevent Insert New Rows Or Columns

May 21, 2009

What is the easiest way to stop users inserting new columns or rows into a workbook? Is it a case of protecting each sheet individually?

View 6 Replies View Related

Unable To Insert Columns Or Rows

Apr 7, 2013

I am unable to insert sheet rows or columns in a microsoft office spread sheet in a specific file. Other files are Ok.

View 14 Replies View Related

Insert Two Columns For Selected Rows

Dec 6, 2008

I would like to select a number of columns and then run a macro that would insert two columns after each of the selected columns.

Or is there perhaps a faster way than using a macro?

View 9 Replies View Related

F4 Does Not Repeat Insert Rows Or Columns

Sep 12, 2009

My F4 key (which I use constantly) works for every "repeat" function except for inserting rows or columns. I can repeat every other option EXCEPT inserting rows/columns. I just had Office 2007 uninstalled and had Office 2003 put back on my PC. My IT group can't figure it out.

View 3 Replies View Related

Insert Number Of Rows Specified In Cell

Feb 7, 2008

I found lots of threads for inserting rows but not the one I need. I'm trying to insert rows with a macro on the position as specified in a cell f.e. in cell D4 I type the number 80 then the macro has to insert three rows at row 80

View 2 Replies View Related

Compare Columns & Insert / Delete Rows

Feb 22, 2008

I have a large data file. In column A is 8760 entries (every hour of every day of the year). Columns D & E are linked, Column D is the time and date whilst Column E is a parameter assocaied with that time and date.

There should also be 8760 entries in these columns, however there are some missing data lines in columns D & E. I would therefore like to move the rows in columns D & E so they match with the entries in column A. Can anyone help? I have a headache as i have over 70 files to complete this operation on.

View 9 Replies View Related

Macro To Insert Defined Number Of Rows

Dec 29, 2008

My first sheet shows the data - a list of audits and their current status.

AuditStageAlphaIn ProgressBetaReportingCharlieCompleteDeltaCompleteOmegaPlanning

I've then used a simple count formula to add up the number by each stage and it's these numbers that I want the macro to use when determining how many rows to input.

Complete2Reporting1In Progress1Planning1

A second worksheet hosts the desired output - a simple report template, split into stages for each status type (completed, planning etc.) with the correct number of rows for each.

Completed AuditsCharlieDeltaReportingBetaAudits in ProgressAlphaAudits in PlanningOmega

So, I want the macro to ensure that we have the right number of rows for each stage, as this month will be run on a monthly basis and the stage each audit is at will change, and the number of rows required in each section will also be different.

View 9 Replies View Related

Insert Columns Based On Tab Description

Apr 14, 2009

I have a macro that inserts a blank column for every sheet in the workbook. The problem i have is that i only want a limited number of columns inserted. I only want a column to be inserted if the sheet tab has the name "detail" in it. I have tried for hours to get this to work, but i keep getting errors. Here is the code i am using.

View 4 Replies View Related

Insert Columns Based On Inputs

Aug 15, 2008

This is for my fantasy football league, so perhaps being familiar with fantasy football will be of help. It's somewhat complicated, so I'm just going to explain what I would like to do: Upon opening the Excel file, there will be a few questions. The first will ask what type of draft, with just two choices, A or B. Below that, it will have inputs asking how many teams, how many players per team, and, if option B was chosen, how many dollars per team. After answering the questions, there should be a button that will "generate" what I'm about to describe.

Choosing option A or B will result in two completely different sheets: -Option A will have X columns for the number of teams entered, and Y rows for the number of players per team. If possible, something will pop up allowing the user to input each team name.

-Option B will be a bit more complicated. I have a template of what one column will be for each team, and would need to have that repeated for the number of teams entered. Additionally, the number of players per team and dollars per team will need to be placed into an existing formula that will perform certain calculations. And, if possible, the number of players per team will alter the column template if the number is over a pre-defined number. And, like the previous option, it would present a pop up allowing the user to input each team name.

I apologize for the length of this question, and while it is too extensive to ask someone here to do, I would like to know what I can expect if I try to achieve this. Will I need to know programming code? Can you point me to some articles that will help me in terms of turning an inputted number into a spreadsheet with that number of columns after hitting a "submit" button?

View 2 Replies View Related

Excel 2007 :: Disable Insert Columns / Rows Only

Mar 1, 2012

I am looking for a way of allowing users to edit the existing cells at their will, but simultaneously disabling the option to insert/ delete columns or rows.

By enabling Sheet Protection, I cannot find a way to do it. Can I?

I am on MS Excel 2007 by the way.

I found the way, just unlock all cells in Format Cells, Protection Tab. Then Protect sheet and de-select what you want to disable.

View 1 Replies View Related

Insert Rows/Columns Without Formula References Changing

Aug 31, 2006

I'm working in a workbook with several sheets, the first two collums of each sheet are =to the first sheet. some times I need to insert a line, but when I did that, I need to type again all formulas or drag the previous ones, and format again the cells. is there another way to do this?

View 4 Replies View Related

Insert A Number Based On A Text Value

Oct 13, 2009

I have a cell (B4)that may contain several different text values, i.e. Bill, Tom, John, Mike, Larry, & Dan. The value in cell D4 needs to relate to what text is in B4, i.e Bill = 6; Tom = 12; John = 8; Mike = 20; Larry = 15; & Dan = 10. I was trying an IF statement, but having trouble.

View 2 Replies View Related

Macro For Spreadsheets With Different Number Of Rows And Constant Number Of Columns?

Mar 1, 2014

I work on a daily basis with spreadsheets in excel. The number of columns is the same, but every single spreadsheet has a different number of rows. I recorded this macro in a table with 1196 rows and I would like to use this macro also in other tables with a different number of rows.

Sub City2()
'
' City2 Macro
'

'
Selection.Copy
Cells.Replace What:="POMPANO", Replacement:="Pompano Beach",

[Code].......

View 12 Replies View Related

VBA To Insert Formula And Then Fill Down Number Of Rows In Reference Column

Apr 8, 2014

I am trying to insert formulas to my cells in different columns and then fill down the formulas as many rows as in the reference column. So far I have put my formulas in a macro but I seem to get problems with " and ' symbols. My macro looks like this:

Sheets("Sold Articles Database").Select
Range("U3").Formula = " =VLOOKUP(LEFT(K3,2),'Input Variables'!$A$48:$B$52,2,FALSE)"
Range("V3").Formula = " =VLOOKUP(K3,'Product datas'!$A$2:$C$10000,3,FALSE)"
Range("W3").Formula = " =VLOOKUP(K3,'Product datas'!$A$2:$D$10000,4,FALSE)"

[Code] ........

View 3 Replies View Related

Insert Rows Based On Cell Value

Jun 24, 2014

I'm working on a large table which has one unique product number followed the number of rows that I want to add below it (for other variants of the same product number).

The Data looks like this:

Column B Column C
12543 2
13456 2
19543 1

I want it to look like this:

Column A Column B
12543
12543
12543
13456
13456
13456
19543
19543

View 2 Replies View Related

Insert Rows Based Upon Value In Cells

Jun 19, 2014

I'm trying to create a macro that will ultimately insert rows based upon a particular value in a range of cells. What I would like to know if there is any way to make active only those cells that contain the letter "X"? Then I would be able to insert rows at that point. I hope I'm making this clear. An example of data is listed:

X ANDY 57.00
X DAVE 43.93
DAVE 92.00
X FRED 4.66
X GREG 23.55
GREG 84.21
GREG 8.69
X MIKE 83.50
X SETH 41.33

to look like:

X ANDY 57.00
X DAVE 43.93
DAVE 92.00
X FRED 4.66

[Code]....

View 3 Replies View Related

Insert Rows Based On Value In Cell

May 16, 2011

Want to run a script to add rows beneath each row based on the value in one of the cells in that row and then move to the next row of data and do the same.

For example:

Cell E5 = 7, I want to Insert 7 rows beneath row 5, then move to the next row and insert the number of cells equal to the value in column E of that row.

View 6 Replies View Related

Insert Rows Based On A Value In A Cell

Jul 14, 2009

I need to create a macro that will insert exact number of rows based on the value in certain cell. e.g. value in cell F2 of sheet1 is 3...so I need to insert 3 rows down from cell F9 in sheet2 copying data in cells D9 and E9 to inserted Cells / rows.

View 4 Replies View Related







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