nrguerrieri
New Member
- Joined
- May 10, 2018
- Messages
- 39
- Office Version
- 365
Need a macro that will find every cell that contains text within columns A to E all the way down to the bottom. Then paste them in that exact order, but all in column A.
Two questions...Need a macro that will find every cell that contains text within columns A to E all the way down to the bottom. Then paste them in that exact order, but all in column A.
Sub Search_Range()
'Modified 5/10/2018 6:15 PM EDT
Application.ScreenUpdating = False
Dim c As Range
Dim Lastrow As Long
Dim i As Long
i = 1
Dim b As Long
For b = 1 To 5
Lastrow = Cells(Rows.Count, b).End(xlUp).Row
For Each c In Cells(1, b).Resize(Lastrow)
If c.Value <> "" Then c.Copy Cells(i, 40): i = i + 1
Next
Next
Columns(40).Copy Columns(1)
Columns(40).ClearContents
Application.ScreenUpdating = True
End Sub
Is there only one text value per row (as shown)? If so, and if there is no other data in Columns F onward, then you this single line of code (executed by itself or along with other code in a macro) will do what you want...its like this here are the columns
A. B. C. D. E
x
x
x
x
*after macro want it to look like
A. B. c. d. e
x
x
x
x
Columns("A:E").SpecialCells(xlBlanks).Delete xlShiftToLeft