Mar 11 2021 05:49 AM
How do I move the specific numbers to a column that correspond to the numbers.. Kindly assist
For example
1,2,3,5,9 and they are about 500 and I want to copy for example 9 to column 9..
Mar 11 2021 06:04 AM
Where are these numbers to start with?
Mar 11 2021 06:09 AM
SolutionHi @Mtumushi
If I understand the requirement correctly, you need below formula:
=IFERROR(INDEX($A:$A,MATCH(COLUMN(),$A:$A,0),1),"")
Please let me know if it works for you. A sample file is also attached for your reference.
Thanks
Tauqeer
Mar 11 2021 06:13 AM
Mar 11 2021 06:15 AM
Mar 11 2021 06:20 AM
Here is a macro you can run. It assumes that the values are in column A, starting in A1.
Sub MoveNumbers()
Dim r As Long
Dim m As Long
Dim a() As String
Dim i As Long
Dim c As Long
Application.ScreenUpdating = False
m = Cells(Rows.Count, 1).End(xlUp).Row
For r = 1 To m
a = Split(Cells(r, 1).Value, ", ")
Cells(r, 1).ClearContents
For i = 0 To UBound(a)
c = a(i)
Cells(r, c).Value = c
Next i
Next r
Application.ScreenUpdating = True
End Sub
Mar 11 2021 06:27 AM
Mar 11 2021 06:28 AM
Mar 11 2021 06:29 AM
I can't do a video conference, if that's what you mean.
Mar 11 2021 06:32 AM
Can you confirm what is the range of multple numbers, I mean the range is 1 to 9 (single digit) or it can be any number for example 312, 7123 etc.
Thanks
Mar 11 2021 06:36 AM
Mar 11 2021 06:37 AM
Mar 11 2021 06:38 AM
Mar 11 2021 07:17 AM
My email address is hans dot vogelaar at gmail dot com
Mar 11 2021 07:43 AM
Thank you for your email. Try this macro:
Sub MoveNumbers()
Dim r As Long
Dim m As Long
Dim a() As String
Dim i As Long
Dim c As Long
Application.ScreenUpdating = False
m = Cells(Rows.Count, 3).End(xlUp).Row
For r = 2 To m
a = Split(Cells(r, 3).Value, ", ")
For i = 0 To UBound(a)
If LCase(a(i)) Like "other*" Then
Cells(r, 11) = "other"
Else
c = a(i)
Cells(r, c + 3).Value = c
End If
Next i
Next r
Application.ScreenUpdating = True
End Sub
Mar 11 2021 01:29 PM
Here is a version of the macro with comments that explain how it works:
Sub MoveNumbers()
Dim r As Long ' Row number
Dim m As Long ' Last row
Dim a() As String ' Array to store the individual parts
Dim i As Long ' Index for looping through the array
Dim c As Long ' Individual part if numeric
' Turn off screen updating to speed up execution
Application.ScreenUpdating = False
' Determine the last row in column 3 (column C)
m = Cells(Rows.Count, 3).End(xlUp).Row
' Loop through the rows from row 2 to row m
For r = 2 To m
' Split the value of the cell in row r, column c
' with comma plus space as delimiter
a = Split(Cells(r, 3).Value, ", ")
' Loop through the array
For i = 0 To UBound(a)
' Check whether the i-th part begins with "other"
If LCase(a(i)) Like "other*" Then
' If so, write "other" in column 11 (column K)
Cells(r, 11) = "other"
Else
' Otherwise, it must be a number
' Set c to the numeric value
c = a(i)
' Write that number to the appropriate column
' 1 in column 4, 2 in column 5 etc.
Cells(r, c + 3).Value = c
End If
Next i
Next r
' Resume screen updating
Application.ScreenUpdating = True
End Sub
Mar 11 2021 09:12 PM
Thank you very much @tauqeeracma. It has perfectly work
Mar 12 2021 03:46 AM
I'm surprised - tauqeeracma's formula, however nice, does something completely different from what you asked...
Mar 12 2021 03:48 AM
@Hans Vogelaar I had no idea what it was... Thank you.. You really assisted
Mar 12 2021 03:55 AM
Your VBA code was excellent and exactly producing the desired result but @Mtumushi was interested in non-VBA solution and he wanted the solution directly in his file through email.
Thanks
Tauqeer
Mar 11 2021 06:09 AM
SolutionHi @Mtumushi
If I understand the requirement correctly, you need below formula:
=IFERROR(INDEX($A:$A,MATCH(COLUMN(),$A:$A,0),1),"")
Please let me know if it works for you. A sample file is also attached for your reference.
Thanks
Tauqeer