Re: Excel VBA Macro for Prioritizing a list
Then you can forget it.
Re: Excel VBA Macro for Prioritizing a list
Then you can forget it.
Re: Excel VBA Macro for Prioritizing a list
Can you upload a workbook with your desired result from the data you provided, clearly showing what exactly you are trying to achieve?
Re: Run-time error '1004'
You might just pasted the code from somewhere I don't remember, but that code needs to be modified to suite your request, not just unprotect/protect.
Re: pastespecial transpose loop
For the data provided.
Sub test()
Dim r As Range, LastR As Range, dic As Object
Dim temp As String, w, e, i As Long, flg As Boolean
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
With Sheets("sheet1").Columns(1).SpecialCells(2)
For Each r In .Areas
temp = GetCategory(r.Value)
If Not dic.exists(temp) Then
ReDim w(1 To 2)
Else
w = dic(temp)
ReDim Preserve w(1 To UBound(w) + 2)
End If
Set w(UBound(w) - 1) = r
Set w(UBound(w)) = r.Offset(, 3).CurrentRegion
dic(temp) = w
Next
End With
With Sheets("sheet2")
For Each e In dic
For i = 1 To UBound(dic(e)) Step 2
Set LastR = .Range("a" & Rows.Count).End(xlUp)(2 + IIf(flg, 1, 0))
flg = False
With LastR
dic(e)(i).Copy .Resize(dic(e)(i + 1).Columns.Count)
dic(e)(i + 1).Copy
.Offset(, 1).PasteSpecial Transpose:=True
End With
Next
flg = True
Next
End With
End Sub
Function GetCategory(txt As String) As String
Dim x
x = Split(txt)
If (UBound(x) > 0) * (IsNumeric(x(UBound(x)))) Then
ReDim Preserve x(UBound(x) - 1)
End If
GetCategory = Join(x)
End Function
Display More
Re: pastespecial transpose loop
Post a sample workbook clearly showing before/after with exact same format to your actual file.
Picture doesn't help at all.
Re: Match + Lookup - VBA
Alternative, different method.
Sub test()
Dim a, e, i As Long, ii As Long, r As Range, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
For Each e In Array("ADM", "LRA")
a = Sheets(e).Cells(1).CurrentRegion.Value
For i = 2 To UBound(a, 1)
If Not dic.exists(a(i, 1)) Then
Set dic(a(i, 1)) = CreateObject("System.Collections.ArrayList")
End If
For ii = 3 To UBound(a, 2)
If a(i, ii) <> "" Then
If dic(a(i, 1)).Contains(a(i, ii)) Then
dic(a(i, 1)).Remove a(i, ii)
Else
dic(a(i, 1)).Add a(i, ii)
End If
End If
Next
Next
Next
With Sheets("Result").Cells(1).CurrentRegion
.Offset(, 3).ClearContents
For Each r In .Columns(1).Cells
If dic.exists(r.Value) Then
If dic(r.Value).Count Then
r(, 4).Resize(, dic(r.Value).Count).Value = dic(r.Value).ToArray
End If
End If
Next
End With
End Sub
Display More
Re: How do I automate to select particular columns from the mastersheet to another sh
Can specify the exact data/row in the file?
Re: How do I automate to select particular columns from the mastersheet to another sh
I have deleted the file from my pc already, so need to see the file.
Re: .additem to a multicolumn listbox
Then I need to see your workbook.
Re: Count the number of occurrences of a character in a cell
Assuming the text is in A1
Sub h()
Dim i As Long, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
For i = 1 To Len([a1])
If Mid$([a1], i, 1) Like "[0-9]" Then dic(Mid$([a1], i, 1)) = dic(Mid$([a1], i, 1)) + 1
Next
If dic.Count Then [b1].Resize(dic.Count, 2).Value = Application.Transpose(Array(dic.keys, dic.items))
End Sub
Re: Combining duplicate entries with unique data in Excel(MAC)
If this doesn't work, I need to see your workbook.
Sub test()
Dim a, i As Long, ii As Long, n As Long, myList, flg As Boolean
With Cells(1).CurrentRegion
a = .Value
For i = 1 To UBound(a, 1)
If Not IsArray(myList) Then
ReDim myList(1 To 1)
Else
For ii = 1 To n
If a(i, 1) = myList(n) Then
flg = True: Exit For
End If
Next
End If
If Not flg Then
n = n + 1
ReDim Preserve myList(1 To n)
myList(n) = a(i, 1)
For ii = 1 To UBound(a, 2)
a(n, ii) = a(i, ii)
Next
Else
For ii = 1 To UBound(a, 2)
If InStr(1, ", " & a(n, ii) & ",", ", " & a(i, ii) & ",", 1) = 0 Then
a(n, ii) = a(n, ii) & ", " & a(i, ii)
End If
Next
flg = False
End If
Next
.Offset(, .Columns.Count + 2).Resize(n).Value = a
End With
End Sub
Display More
Re: VBA to Consolidate and append data from several workbooks to one master file
ArrayList
See
https://msdn.microsoft.com/en-….arraylist(v=vs.110).aspx
Eveything is in vb Help.
Brief explanation.
1) Store each heading in ArrayList for creating unite heading for output.
2) Each dictionary store unique col.A value and store each corresponding info in its child dictionry.
3) Output all the info regarding all the unique Col.A value to the worksheet.
Re: VBA - first to match Name with data range and perform Hlookup
You are asking the question which is not related to your original question.
By the forum rule, you need to open a new thread for the new question.
Re: How do I automate to select particular columns from the mastersheet to another sh
See if this is how you wanted.
Sub test()
Dim a, i As Long, ii As Long, n As Long, dic As Object
Dim sDate As Date, eDate As Date, temp As Date, myTbl As ListObject
Const myStyle As String = "TableStyleMedium9"
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("sheet1").Cells(1).CurrentRegion
sDate = Application.Min(.Columns("ay"))
sDate = sDate - Day(sDate) + 1
eDate = Application.Max(.Columns("ay"))
eDate = eDate - Day(eDate) + 1
a = .Value
End With
Do
temp = DateAdd("m", n, sDate)
Set dic(Format$(temp, "mmmm, yyyy")) = _
CreateObject("System.Collections.ArrayList")
n = n + 1
Loop While temp < eDate
For i = 2 To UBound(a, 1)
If a(i, 51) <> "" Then
a(i, 51) = Format$(a(i, 51), "mmmm, yyyy")
dic(a(i, 51)).Add _
Join(Array(a(i, 4), Format$(a(i, 51), "mm/dd/yyyy")), " - ")
End If
Next
With Sheets("OutPut")
.Cells.Delete
With .Cells(1).Resize(, dic.Count)
.Value = dic.keys
For ii = 1 To .Columns.Count
If dic(.Cells(1, ii).Value).Count > 0 Then
.Cells(2, ii).Resize(dic(.Cells(1, ii).Value).Count).Value = _
Application.Transpose(dic(.Cells(1, ii).Value).ToArray)
End If
Next
End With
With .Cells(1).CurrentRegion
.Rows(1).Font.Size = 12
Set myTbl = .Parent.ListObjects.Add(1, .Cells, , 1)
myTbl.TableStyle = myStyle
myTbl.ShowAutoFilter = False
.RowHeight = 40.25
.VerticalAlignment = xlTop
.HorizontalAlignment = xlCenter
.Columns.AutoFit
End With
.Select
End With
End Sub
Display More
Re: How do I automate to select particular columns from the mastersheet to another sh
Use the free file storage like filedropper