Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move cell contents with macro Peridot Excel Discussion (Misc queries) 4 September 30th 09 03:35 PM
Macro to move cell contents based on formatting Scott Wagner Excel Programming 2 December 23rd 05 03:22 PM
Macro to move the contents of a cell JenBasch Excel Programming 1 September 20th 05 01:47 AM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Macro to move selected cell contents to a specific column on same row Ben Johnson[_3_] Excel Programming 1 February 10th 04 08:43 PM


All times are GMT +1. The time now is 09:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"