All Method (Formula, VBA, ...)
All Method (Formula, VBA, ...)
Hi
Try
Sub test() Dim a, b As Variant Dim i, l As Long l = 1 a = Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row) ReDim b(1 To UBound(a), 1 To 3) For i = l To UBound(a) / 3 - 1 If a(l, 1) <> a(l + 1, 1) Then b(l, 1) = a(l, 1): b(l, 2) = a(l + 1, 1): b(l, 3) = a(l + 2, 1) l = l + 3 Else l = l + 1 b(l, 1) = a(l, 1): b(l, 2) = a(l + 1, 1): b(l, 3) = a(l + 2, 1) l = l + 3 End If Next Cells(1, 7).Resize(UBound(b, 1), UBound(b, 2)) = b End Sub
Last edited by mohadin; 11-02-2020 at 03:49 AM.
mohadin. Great.
In another case, if there are more than 2 cells under a text box or there is only 1 number format cell, how to edit the code above?
Thank you
Simply
Sub test() Dim r As Range For Each r In Columns(1).SpecialCells(2, 1).Areas r(0, 3) = r(0).Value r(0, 4).Resize(, r.Count).FormulaArray = "=transpose(" & r.Address & ")" Next End Sub
jindon is very nice. Your code solved my other case, thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks