Pramodpandit123
New Member
- Joined
- Apr 18, 2020
- Messages
- 30
- Office Version
- 2016
- Platform
- Windows
I wanted to get Multiple Rows & Columns Data and stack it into single column in Excel.
Below is the code i used :
The problem is lastcol give the last cell having the data whereas i want the number of datas within the specific range/Column.
For eg: My datas are within Column D to Column F only. Beyound column F there are unrelated datas.
So i wanted to get number of columns having data within Column D to Column F only.
Below is the code i used :
VBA Code:
Sub SingleColumn()
r = 3
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
For i = 1 To lastrow
lastcol = Cells(i + 2, Columns.Count).End(xlToLeft).Column
For j = 1 To lastcol
If Cells(i + 2, j + 3).Value <> "" Then
Cells(i + 2, j + 3).Copy Range("M" & r)
r = r + 1
Else
Exit For
End If
Next j
Next i
End Sub
For eg: My datas are within Column D to Column F only. Beyound column F there are unrelated datas.
So i wanted to get number of columns having data within Column D to Column F only.