[COLOR="Navy"]Sub[/COLOR] MG31May58
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Sheets("Sheet1").Range("A1").CurrentRegion
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Dn <> "" [COLOR="Navy"]Then[/COLOR]
c = c + 1
Sheets("sheet3").Range("A" & c) = Dn '[COLOR="Green"][B]Sheet3 = destination Sheet[/B][/COLOR]
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Make sure you have a sheet of that name.
If not the problem please show an example of your sheet and the approx size of the range.
NB:- To show sheet place a Border around each cell within the range to be copied ,to form a grid. Copy and paste range to the Thread.
Mick
But it is not robust if the following is true:Dear Mick
It works.
Many Thanks
Balaji
For example, with the following layout, only the blue cells would get copied to Sheet3.The length of the columns is varies and it also contains gaps or some columns are empty.
Excel Workbook | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | gdg | gj | df | |||
2 | gsdf | gj | gfd | |||
3 | g | j | ||||
4 | g | f | ||||
5 | g | |||||
6 | dfg | f | ||||
7 | hfg | df | ||||
8 | hfg | fg | ||||
9 | ||||||
Sheet1 |