Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
macro to move cell contents and then delete the row
I have a single column of data located in Column A similar as follows:
"Column A" "Column B" "Column 3" "....." Example1* * data1 Example2* * data2 Example3* * data3 and so on. What I want to do is have a macro to move the contents as follows: "Column A" "Column B" "Column 3" "....." Example1* * 1 Example2* * 2 Example3* * 3 Then I want to delete the empty rows where the data used to be. Is this possible? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
macro to move cell contents and then delete the row
You can try this with
* data1 starting in row 2 in the A column This example loop through 100 rows Sub Testing() For I = 2 To 100 Step 2 Cells(I, 1).Cut Cells(I - 1, 2) Next I On Error Resume Next 'In case there are no blank cells Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Mark64" wrote in message ... I have a single column of data located in Column A similar as follows: "Column A" "Column B" "Column 3" "....." Example1* * data1 Example2* * data2 Example3* * data3 and so on. What I want to do is have a macro to move the contents as follows: "Column A" "Column B" "Column 3" "....." Example1* * 1 Example2* * 2 Example3* * 3 Then I want to delete the empty rows where the data used to be. Is this possible? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
macro to move cell contents and then delete the row
Note that I use
Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete Change Columns("A"). To a range if you not want to check the whole column -- Regards Ron de Bruin http://www.rondebruin.nl "Ron de Bruin" wrote in message ... You can try this with * data1 starting in row 2 in the A column This example loop through 100 rows Sub Testing() For I = 2 To 100 Step 2 Cells(I, 1).Cut Cells(I - 1, 2) Next I On Error Resume Next 'In case there are no blank cells Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Mark64" wrote in message ... I have a single column of data located in Column A similar as follows: "Column A" "Column B" "Column 3" "....." Example1* * data1 Example2* * data2 Example3* * data3 and so on. What I want to do is have a macro to move the contents as follows: "Column A" "Column B" "Column 3" "....." Example1* * 1 Example2* * 2 Example3* * 3 Then I want to delete the empty rows where the data used to be. Is this possible? Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
macro to move cell contents and then delete the row
Like this
lr = is the last cell with a value in A Sub Testing2() Dim lr As Long lr = Range("A" & Rows.Count).End(xlUp).Row For I = 2 To lr Step 2 Cells(I, 1).Cut Cells(I - 1, 2) Next I On Error Resume Next 'In case there are no blank cells Range(Cells(1, 1), Cells(lr, 1)).SpecialCells(xlCellTypeBlanks).EntireRow.Delet e On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Ron de Bruin" wrote in message ... Note that I use Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete Change Columns("A"). To a range if you not want to check the whole column -- Regards Ron de Bruin http://www.rondebruin.nl "Ron de Bruin" wrote in message ... You can try this with * data1 starting in row 2 in the A column This example loop through 100 rows Sub Testing() For I = 2 To 100 Step 2 Cells(I, 1).Cut Cells(I - 1, 2) Next I On Error Resume Next 'In case there are no blank cells Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Mark64" wrote in message ... I have a single column of data located in Column A similar as follows: "Column A" "Column B" "Column 3" "....." Example1* * data1 Example2* * data2 Example3* * data3 and so on. What I want to do is have a macro to move the contents as follows: "Column A" "Column B" "Column 3" "....." Example1* * 1 Example2* * 2 Example3* * 3 Then I want to delete the empty rows where the data used to be. Is this possible? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Move cell contents with macro | Excel Discussion (Misc queries) | |||
Macro to move cell contents based on formatting | Excel Programming | |||
Macro to move the contents of a cell | Excel Programming | |||
Macro to remove contents of cell and move all other contents up one row | Excel Discussion (Misc queries) | |||
Macro to move selected cell contents to a specific column on same row | Excel Programming |