Attached is a sample spreadsheet of what I have and what I want it to look like. Any help would be greatly appreciated to create a macro to run. Also, is there a resource where I can learn to write macros?
Thanks
Attached is a sample spreadsheet of what I have and what I want it to look like. Any help would be greatly appreciated to create a macro to run. Also, is there a resource where I can learn to write macros?
Thanks
Last edited by theatergirl; 03-21-2013 at 10:20 AM.
On the output section, you have data in column N. I can not follow the logic
With column N, i just want the content of the cell to go to the next row up if the customer number in column a matches. Does that make sense?
This should do what you want.
![]()
Option Explicit Sub test() Dim a, i As Long, ii As Long, n As Long, t As Long, w a = Sheets("sheet1").Cells(1).CurrentRegion.Value t = UBound(a, 2) ReDim Preserve a(1 To UBound(a, 1), 1 To UBound(a, 2) + 10) With CreateObject("Scripting.Dictionary") .CompareMode = 1 For i = 1 To UBound(a, 1) If Not .exists(a(i, 1)) Then n = n + 1: .Item(a(i, 1)) = VBA.Array(n, t) For ii = 1 To UBound(a, 2) a(n, ii) = a(i, ii) Next Else w = .Item(a(i, 1)) w(1) = w(1) + 1 If w(1) > UBound(a, 2) Then ReDim Preserve a(1 To UBound(a, 1), 1 To UBound(a, 2) + 10) End If a(w(0), w(1)) = a(i, t) .Item(a(i, 1)) = w End If Next End With With Sheets.Add().Cells(1).Resize(n, UBound(a, 2)) .Value = a .Columns.AutoFit End With End Sub
Jindon has provided you a solution!
when i try to run it, i get an error that says Run-time error '9': Subscript out of range
When I run it, I did not get any error. In which line does the error highlight with yellow color error?
this is what i get. sorry i am not good with these
Okay!
In your original data you have sheet1. You need to change the sheet name from sheet1 in to your actual sheet name. You do not have to worry about the result as a new sheet name is added. What is the name of the sheet you now have, if you struggle I can amend it for you? Just change the sheet name and run it and will see the result on new added sheet.
Change
to![]()
a = Sheets("sheet1").Cells(1).CurrentRegion.Value
![]()
a = Cells(1).CurrentRegion.Value
Now I get Run-time error '1004': Application-defined or object-defined error and it creates a new sheet each time I try to run it.
.............
I was able to put my spreadsheet into this one and get it to work! thank you so much for your help and patience!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks