I have a fairly large spreadsheet that are sorted based on a file # (ie:
E0800100, E0800101). The spreadsheet is setup to where each entry is on an
individual row as seen below:
A B C
E0800100 Review.... 1.0 (hr)
E0800100 Review.... 2.0
E0800101 Review.... 1.5
E0800102 Review.... .5
I am trying to organize the spreadsheet so that there is only one row per
file number and the Descriptions (B) and Time (C) extend along the columns of
that row.
A. B. C.
D. E.
E0800100 Review.... 1.0
Review..... 2.0
E0900101 Review.... 1.5
E0900102 Review... .5
The spreadsheet is not consistent in that there are 2 or 3 entries for every
file number but ranges from 1-15 entries. I attempted to combine various
macro formulas I've seen but have had no such luck and am at a loss to if
this is possible. Any information or direction to getting this as close as
possible would be appreciated.
|
|
0
|
|
|
|
Reply
|
Utf
|
5/25/2010 6:11:02 PM |
|
Hi rsklhm
Using Excel 2003 I have created this:
Sub MergeOnColumnA()
Dim lastRow As Long
Dim loopRow As Long
lastRow = Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row + 1
loopRow = ActiveCell.Row
Do While loopRow < lastRow
Cells(loopRow, 1).Select
If Cells(loopRow, 1).Value = Cells(loopRow - 1, 1).Value Then
Cells(loopRow - 1, 1).End(xlToRight).Offset(0, 1).Value = _
Cells(loopRow, 2)
Cells(loopRow - 1, 1).End(xlToRight).Offset(0, 1).Value = _
Cells(loopRow, 3)
Rows(loopRow).Delete
lastRow = lastRow - 1
Else
loopRow = loopRow + 1
End If
Loop
End Sub
HTH,
Wouter
|
|
0
|
|
|
|
Reply
|
Wouter
|
5/25/2010 8:10:59 PM
|
|
Hello Wouter,
I have tried your program and think that the fifth line of:
loopRow=ActiveCell.Row
should be replaced with:
loopRow=2
Best Regards,
Gabor Sebo
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
"Wouter HM" <wouter.magre@sogeti.nl> wrote in message
news:191be05e-459c-4f05-9dc5-1175c41d3054@w3g2000vbd.googlegroups.com...
> Hi rsklhm
>
> Using Excel 2003 I have created this:
>
> Sub MergeOnColumnA()
> Dim lastRow As Long
> Dim loopRow As Long
>
> lastRow = Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row + 1
>
> loopRow = ActiveCell.Row
> Do While loopRow < lastRow
> Cells(loopRow, 1).Select
> If Cells(loopRow, 1).Value = Cells(loopRow - 1, 1).Value Then
> Cells(loopRow - 1, 1).End(xlToRight).Offset(0, 1).Value = _
> Cells(loopRow, 2)
> Cells(loopRow - 1, 1).End(xlToRight).Offset(0, 1).Value = _
> Cells(loopRow, 3)
> Rows(loopRow).Delete
> lastRow = lastRow - 1
> Else
> loopRow = loopRow + 1
> End If
> Loop
>
> End Sub
>
> HTH,
>
> Wouter
|
|
0
|
|
|
|
Reply
|
helene
|
5/26/2010 12:15:52 AM
|
|
e0800100 review 3.5 e0800100 review 3.5
review 4.5 e0800100 review 4.5
review 5.5 e0800100 review 5.5
e0800101 review 2.5 e0800101 review 2.5
review 2.5 e0800101 review 2.5
review 3.5 e0800101 review 3.5
review 52.5 e0800101 review 52.5
e0800201 review 52.5 e0800201 review 52.5
e0800202 review 52.5 e0800202 review 52.5
e0800402 review 52.5 e0800402 review 52.5
review 52.5 e0800402 review 52.5
review 52.5 e0800402 review 52.5
review 52.5 e0800402 review 52.5
OUTPUT INPUT
'Hi rsklhm
Sub MergeOnColumnA()
Dim lastRow As Long
Dim loopRow As Long
Dim i As Integer
Dim last As String
lastRow = Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row + 1
For i = 2 To lastRow
If i = 2 Then
last = Cells(i - 1, 1).Value
End If
If Cells(i, 1) = last Or Cells(i, 1) = Cells(i - 1, 1).Value Then
Cells(i, 1) = Cells(i, 2).Value
Cells(i, 2) = Cells(i, 3).Value
Cells(i, 3) = ""
End If
If Cells(i, 3) <> "" Then
last = Cells(i, 1).Value
End If
Next i
End Sub
Hello,
Input, output and program attached.
Best Regards
Gabor Sebo
"rsklhm" <rsklhm@discussions.microsoft.com> wrote in message
news:85E4B28D-F114-4253-A995-AF3902314C4B@microsoft.com...
|
|
0
|
|
|
|
Reply
|
helene
|
5/26/2010 12:08:53 PM
|
|
Assumes you have sorted first
'=======
Option Explicit
Sub lineemupSAS()
Dim i As Long
Dim lc As Long
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If Cells(i - 1, 1) = Cells(i, 1) Then
lc = Cells(i - 1, Columns.Count).End(xlToLeft).Column + 1
Cells(i - 1, lc) = Cells(i, 2)
Cells(i - 1, lc + 1) = Cells(i, 3)
Rows(i).Delete
End If
Next i
End Sub
'=========
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett@gmail.com
"rsklhm" <rsklhm@discussions.microsoft.com> wrote in message
news:85E4B28D-F114-4253-A995-AF3902314C4B@microsoft.com...
>I have a fairly large spreadsheet that are sorted based on a file # (ie:
> E0800100, E0800101). The spreadsheet is setup to where each entry is on
> an
> individual row as seen below:
>
> A B C
> E0800100 Review.... 1.0 (hr)
> E0800100 Review.... 2.0
> E0800101 Review.... 1.5
> E0800102 Review.... .5
>
> I am trying to organize the spreadsheet so that there is only one row per
> file number and the Descriptions (B) and Time (C) extend along the columns
> of
> that row.
>
> A. B. C.
> D. E.
> E0800100 Review.... 1.0
> Review..... 2.0
> E0900101 Review.... 1.5
> E0900102 Review... .5
>
> The spreadsheet is not consistent in that there are 2 or 3 entries for
> every
> file number but ranges from 1-15 entries. I attempted to combine various
> macro formulas I've seen but have had no such luck and am at a loss to if
> this is possible. Any information or direction to getting this as close
> as
> possible would be appreciated.
|
|
0
|
|
|
|
Reply
|
Don
|
5/26/2010 12:55:26 PM
|
|
|
4 Replies
391 Views
(page loaded in 0.073 seconds)
Similiar Articles: macro to merge two table cells? - microsoft.public.word ...Merge and Unmerge Cells - Welcome to the MVPs.org home page! The middle table shows the results of using MergeRxR macro so that columns and not rows are merged ... Macro to merge workbooks onto one worksheet - microsoft.public ...macro to merge two table cells? - microsoft.public.word ... Macro to merge workbooks onto one worksheet - microsoft.public ... macro to merge two table cells? - microsoft ... allow merging cells in protected sheet - microsoft.public.excel ...Do I have to temporarily unlock the cell ... Basic for Applications macros to ... I've tried Format/lock cell and then ... allow merging cells in protected sheet ... Merging Tables, Adding Rows--Word 2007, Win7 - microsoft.public ...Merging Tables, Adding Rows--Word 2007, Win7 - microsoft.public ... Or you can insert one, select two, press F4 ... macro to merge two table cells? - microsoft.public ... Combine two cells without losing data cell formats - microsoft ...I need a macro, or a function to combine 2 columns of data into one column ... to Merge Cells in Excel without Losing Data [Microsoft Excel ..... way to merge cells ... Set Cell Padding on word tables with merged cells - microsoft ...macro to merge two table cells? - microsoft.public.word ... Set Cell Padding on word tables with merged cells - microsoft ... macro to merge two table cells? - microsoft ... MACRO for moving rows from one worksheet to another - microsoft ...Macro to merge workbooks onto one worksheet - microsoft.public ... MACRO for moving rows from one worksheet to another - microsoft ... Macro to merge workbooks onto one ... Bug with cell merging in tables using Applescript - microsoft ...Form problems in a table with merged cells - microsoft.public ... Cant merge cell - microsoft.public.excel.misc macro to merge two table cells ... in same cell without ... macro triggered by changes to cell only works if i run it twice ...... Target.Row = 12 Then Call ChangeStops End If HTH Bob "oli merge ... row to do the work in the macro. ... created the sheets you can run this macro ... Cells ... Macro to subtract cells if... - microsoft.public.excel.programming ...macro to merge two table cells? - microsoft.public.word ... I've trying unsuccessfully to record a macro that will merge a table cell with the cell ... Merge and Unmerge Cells - Welcome to the MVPs.org home page!Merging and Unmerging Cells and macros to help with merging cells based on selections by rows, by columns, by groups Macro Required - Automatically Merge Vertically Identical CellsMacro Required - Automatically Merge Vertically Identical Cells - Hi There I was wondering if someone can help After... - Free Excel Help Excel - Merging Every Three Rows - I want to write... - Free Excel ...Merging Every Three Rows - I want to write a macro that will merge every three... - Free Excel Help Using Macro to merge cells - Microsoft Corporation: Software ...Hi, I'm trying to create a macro or some kind of script to merge two cell's information into 1. this is how it looks like Row A is the first name and row B ... Excel Macro to Merge First Two Cells of Each Column « RGB Triple ZExcel Macro to Merge First Two Cells of Each Column. Once in a while you may run into an Excel spreadsheet in which the first two rows have been used for column ... 7/25/2012 3:35:05 PM
|