Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Hi,
This is not very sophisticated but seems to work with the data you provided. Sub tryme() LastRow = Cells(Rows.Count, "A").End(xlUp).Row For j = 1 To LastRow LastCol = Cells(j, Columns.Count).End(xlToLeft).Column If LastCol < 7 Then Range(Cells(j + 1, 1), Cells(j + 1, 10)).Copy Destination:=Cells(j, 5) Cells(j + 1, "A") = "VOID" LastCol = Cells(j, Columns.Count).End(xlToLeft).Column For k = LastCol To 1 Step -1 If IsEmpty(Cells(j, k)) Then Cells(j, k).Delete Shift:=xlToLeft End If Next k End If Next j 'delete marked rows For j = LastRow To 1 Step -1 If Cells(j, "A") = "VOID" Then Rows(j).EntireRow.Delete End If Next j best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme "Atom Oaks" wrote in message ... Sorry, I did not realize that the format changed after I posted. This is how my worksheet looks: Purple Purple Purple Purple* Purple " " " Green Green Green* Blue Blue Blue Blue Red Red Red* Yellow Yellow Yellow Yellow* Yellow " " " Orange Orange Orange* Brown Brown Brown Brown Teal Teal Teal* Black Black Black Black Grey Grey Grey* " = 1 blank cell * = end of row And I am trying to find and combine all the duplicate rows in Column A so that my work sheet looks like this: Purple Purple Purple Purple Green Green Green* Blue Blue Blue Blue Red Red Red* Yellow Yellow Yellow Yellow Orange Orange Orange* Brown Brown Brown Brown Teal Teal Teal* Black Black Black Black Grey Grey Grey* So far, this is what I have come up with: Sub CombineDelete() ' ' Macro2 Macro ' Macro recorded 1/8/2010 by Information Systems ' ' Keyboard Shortcut: Ctrl+q ' Range(ActiveCell, ActiveCell.Offset(0, 10)).Select Selection.Cut ActiveCell.Offset(1, 0).Select ActiveSheet.Paste ActiveCell.Offset(-1, 0).Select Selection.EntireRow.Delete End Sub It does the job, but requires that I manually locate the duplicates and use a hotkey. So any ideas would be greatly appreciated. Hopefully this post is much better. Thank you! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
creating macros | Excel Discussion (Misc queries) | |||
Creating macros with if stmts | Excel Discussion (Misc queries) | |||
macros creating | Excel Discussion (Misc queries) | |||
creating excel macros | Excel Worksheet Functions | |||
Macros-creating new sheets | Excel Worksheet Functions |