Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jc jc is offline
external usenet poster
 
Posts: 164
Default Create a new row when data present in a column

I have a spreadsheet in which columns E - I are references to column C and
may or may not contain data (one to one or one to many). I would like to
insert a new row, copying the data in A - D for each time there is data
contiained in columns E - I.

ex. (Would want to see as three rows for data in E, F and I)
A B C D E F
G H I
Client Manager Control# Control Name Code1 Code2 Blank Blank
Code3
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 471
Default Create a new row when data present in a column

Do you want the old rows and then the new rows or do you want old row, old
row, then if old row has something in E-I, new rows inserted right there or
placed at the bottom of the existing data? Or do you just want the new rows
or the old rows if no new rows are made?

"JC" wrote:

I have a spreadsheet in which columns E - I are references to column C and
may or may not contain data (one to one or one to many). I would like to
insert a new row, copying the data in A - D for each time there is data
contiained in columns E - I.

ex. (Would want to see as three rows for data in E, F and I)
A B C D E F
G H I
Client Manager Control# Control Name Code1 Code2 Blank Blank
Code3

  #3   Report Post  
Posted to microsoft.public.excel.misc
jc jc is offline
external usenet poster
 
Posts: 164
Default Create a new row when data present in a column

I would want new rows. The old row would not be needed once the data from
columns E - I was transposed (new column) into the new rows. There will
always be at least one of those cells with data (always one to one or one to
many; never one to none).

"Mike H." wrote:

Do you want the old rows and then the new rows or do you want old row, old
row, then if old row has something in E-I, new rows inserted right there or
placed at the bottom of the existing data? Or do you just want the new rows
or the old rows if no new rows are made?

"JC" wrote:

I have a spreadsheet in which columns E - I are references to column C and
may or may not contain data (one to one or one to many). I would like to
insert a new row, copying the data in A - D for each time there is data
contiained in columns E - I.

ex. (Would want to see as three rows for data in E, F and I)
A B C D E F
G H I
Client Manager Control# Control Name Code1 Code2 Blank Blank
Code3

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 471
Default Create a new row when data present in a column

This would work:

Sub CreateNew()
Dim dataArray(5000, 5) As Variant
Dim x As Long
Dim Y As Long
Dim Fnd As Long
x = 2
Do While True
If Cells(x, 1).Value = Empty Then Exit Do
For Y = 5 To 8
If Cells(x, Y).Value < "" Then
Fnd = Fnd + 1
For Z = 1 To 4
dataarray(Fnd, Z) = Cells(x, Z)
Next
dataarray(Fnd, 5) = Cells(x, Y)
End If
Next
x = x + 1
Loop


Dim MyEntries As String
Workbooks.Add Template:="Workbook"
MyEntries = ActiveWorkbook.Name
Cells(1, 1) = "Client"
Cells(1, 2).Value = "Manager"
Cells(1, 3).Value = "Control#"
Cells(1, 4).Value = "Control Name"
Cells(1, 5).Value = "Code"
For x = 1 To Fnd
For Y = 1 To 5
Cells(x + 1, Y).Value = dataarray(x, Y)
Next
Next
Cells.Select
Cells.EntireColumn.AutoFit
Set PrtRng = Range(Cells(1, 1), Cells(Fnd + 2, 5))
With ActiveSheet.PageSetup
.Zoom = False
.PrintArea = PrtRng.Address
.PrintTitleRows = "$1:$1"
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 10
End With
Cells(2, 1).Select
ActiveWindow.FreezePanes = True
ActiveWindow.SelectedSheets.PrintPreview


End Sub


  #5   Report Post  
Posted to microsoft.public.excel.misc
jc jc is offline
external usenet poster
 
Posts: 164
Default Create a new row when data present in a column

Perfect! and thank you for allowing me to borrow from your genius.

"Mike H." wrote:

This would work:

Sub CreateNew()
Dim dataArray(5000, 5) As Variant
Dim x As Long
Dim Y As Long
Dim Fnd As Long
x = 2
Do While True
If Cells(x, 1).Value = Empty Then Exit Do
For Y = 5 To 8
If Cells(x, Y).Value < "" Then
Fnd = Fnd + 1
For Z = 1 To 4
dataarray(Fnd, Z) = Cells(x, Z)
Next
dataarray(Fnd, 5) = Cells(x, Y)
End If
Next
x = x + 1
Loop


Dim MyEntries As String
Workbooks.Add Template:="Workbook"
MyEntries = ActiveWorkbook.Name
Cells(1, 1) = "Client"
Cells(1, 2).Value = "Manager"
Cells(1, 3).Value = "Control#"
Cells(1, 4).Value = "Control Name"
Cells(1, 5).Value = "Code"
For x = 1 To Fnd
For Y = 1 To 5
Cells(x + 1, Y).Value = dataarray(x, Y)
Next
Next
Cells.Select
Cells.EntireColumn.AutoFit
Set PrtRng = Range(Cells(1, 1), Cells(Fnd + 2, 5))
With ActiveSheet.PageSetup
.Zoom = False
.PrintArea = PrtRng.Address
.PrintTitleRows = "$1:$1"
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 10
End With
Cells(2, 1).Select
ActiveWindow.FreezePanes = True
ActiveWindow.SelectedSheets.PrintPreview


End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding text to column cell if there's a value present Tim R Excel Discussion (Misc queries) 3 October 23rd 07 10:30 PM
include in new column only if present in both columns jb Excel Worksheet Functions 1 September 21st 07 10:16 PM
Need to parse column data only when text is present Phil Excel Worksheet Functions 0 July 10th 07 08:22 PM
Create a database of past and present customers Pepsee777 Excel Discussion (Misc queries) 0 May 30th 06 08:56 PM
SUM/COUNT column(s) based on specific value present within the column markx Excel Worksheet Functions 6 March 22nd 05 10:23 AM


All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"