Find values on an a range of columns and rows and copy them to a column

vladi305

Board Regular
Joined
Jan 12, 2023
Messages
88
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have groups of data on a range of columns and row. Some of those are blank. The solution will be to copy into a column the cells that contain a value.
Notice the picture attached. The groups are the one left wIth a background filled and the column is the one on the right
 

Attachments

  • Screenshot_20230215-140601_Excel.jpg
    Screenshot_20230215-140601_Excel.jpg
    152.1 KB · Views: 11
I've no idea, can you post the data & formulae using the XL2BB add-in?
Ok so on the worksheet after I started adding the formulas it will stop working
With simple formulas as =J22+2 it will but =IF(Freq!U$17<10,Freq!U$3,"") won't read it

Formula 1 will read everything but obviously leave blanks: =TOCOL(B8:J9,3)
Formula 2 will read and copy the values leaving the blanks but again only simple formulas: =TOCOL(IF(B8:K9="",x,B8:K9),3)
I tried modifying the formula to =TOCOL(IF(B8:K9<>"",B8:K9,x),3)


The IF conditions reads all fine, see the pic attached
 

Attachments

  • Pic49.jpg
    Pic49.jpg
    50.9 KB · Views: 5
  • Pic50.jpg
    Pic50.jpg
    46.7 KB · Views: 6
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Ok guys I had to resource to VBA and but it works fine now:
If you find a better solution not using VBA I'd like to use that

Here's the function:

Function TOCOLUMNS(SearchRange As Range)
Dim v As Variant ' Multi-purpose array
Dim c As Variant ' Element of array (corresponds to cell)
Dim d As Object ' Scripting.Dictionary object
Dim i As Long ' Loop index for bubble sort
Dim j As Long ' Idem
Dim t As Variant ' Placeholder for sort
' Create a Dictionary object
Set d = CreateObject("Scripting.Dictionary")
' Store values of SearchRange in a two-dimensional array
v = SearchRange.Value
' Loop through the array elements (cells)
For Each c In v
' Only use non-blank values
If c <> "" Then
' Set the dictionary entry with key c to 1
' If that entry doesn't exist yet, it will be created
' If it already existed, nothing will change
' This way, we collect the unique values
d(c) = 1
End If
Next c
' Set v to the array of keys of the dictionary
' The array contains the unique values
v = d.Keys
' Use the simple bubble sort algorithm to sort the array
For i = LBound(v) To UBound(v) - 1
For j = i + 1 To UBound(v)
' If an element is larger than a later element...
If v(i) > v(j) Then
' ... then swap the elements
t = v(i)
v(i) = v(j)
v(j) = t
End If
Next j
Next i
' v is now an array laid out in a row
' Return the array transposed to a column
TOCOLUMNS = Application.Transpose(v)
End Function
 
Upvote 0

Forum statistics

Threads
1,216,272
Messages
6,129,822
Members
449,538
Latest member
cookie2956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top