Split Cell values

mijaz

New Member
Joined
Aug 15, 2011
Messages
6
I have following data in each cell of Column D; for example cell D1 contains:

1
2
3
4
5
Above are the values in D1, similar data exists from D1 to D10000. I need to split these values into adjacent empty columns(cells). Text to columns does not work here because separating value is Alt+Enter which Text to Columns does not recognize. I probably need some VBA code for this. And need your help in this regard.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Thanks a lot for doing this favor. It was really great.


Though I have another query. There are two columns. Column A and B. Column A has numerics. Column B has values against it. There are upto 10 values against one number in different rows i.e.

Column A column B
A1= 1 B1= Pakistan
A2= Blank B2= India
A3=Blank B3= Indonesia

etc.

I wish to transfer Column B values in Column C1, D1, E1, F1. I mean upto the number of values against cell A1. Is it possible? In other words i want this data in one row. Kindly help.
 
Upvote 0
Does this code do what you want...

Code:
Sub TransposeDataAcross()
  Dim LastRow As Long, Blanks As Range, Ar As Range
  Const StartRow As Long = 1
  LastRow = Cells(Rows.Count, "B").End(xlUp).Row
  Set Blanks = Cells(StartRow, "A").Resize(LastRow - StartRow + 1).SpecialCells(xlCellTypeBlanks)
  For Each Ar In Blanks.Areas
    Ar(1).Offset(-1, 2).Resize(, Ar.Rows.Count) = WorksheetFunction.Transpose(Ar.Offset(, 1))
  Next
  Blanks.EntireRow.Delete
End Sub
 
Upvote 0
Thanks very much dear.

One last query please i.e.


If a cell is blank in Column A, then copy the data from above cell and paste it in the blank cell.
 
Upvote 0
One last query please i.e.

If a cell is blank in Column A, then copy the data from above cell and paste it in the blank cell.
Give this macro a try...

Code:
Sub FillBlanks()
  Dim LastRow As Long
  Const StartRow As Long = 2
  LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
            SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
  With Cells(StartRow, "A").Resize(LastRow - StartRow + 1)
    .SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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