Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Macro code help - re pasting rows

Hi I am trying to put data from two rows onto one row -

I have thousands of rows but I need help in coming up with a way o
doing the job in bulk.

The code below represents what I want to do i.e. take every even ro
(starting at row 8) and paste it onto the end of the previous row.


Sub Consol()

Range("A8:M8").Select
Selection.Cut
Range("A10:M10").Select
Selection.Cut
Range("A12:M12").Select
Selection.Cut

End Sub


Your help would be much appreciated.

Thanks

Bria

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Excel Macro code help - re pasting rows

Sub CutNPaste()
Dim rng As Range

Set rng = [a8:m8]
While rng(1, 1) < ""
rng.Cut rng.Offset(-1, rng.Columns.Count)
Set rng = rng.Offset(3, -rng.Columns.Count)
Wend
DeleteEmptyRows

End Sub

Function DeleteEmptyRows()
'Dave Braden excel.programming
Dim L As Long, rng As Range

On Error Resume Next
With ActiveSheet.UsedRange.Columns
Set rng = .Item(1).SpecialCells(4).EntireRow
If rng Is Nothing Then Exit Function
'adapted to start at row8, normally starts at l=2
For L = 8 To .Count
Set rng = Intersect(rng, .Item(L).SpecialCells(4).EntireRow)
If rng Is Nothing Then Exit Function
Next
End With
rng.Delete
End Function



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


bjmccready wrote:

Hi I am trying to put data from two rows onto one row -

I have thousands of rows but I need help in coming up with a way of
doing the job in bulk.

The code below represents what I want to do i.e. take every even row
(starting at row 8) and paste it onto the end of the previous row.


Sub Consol()

Range("A8:M8").Select
Selection.Cut
Range("A10:M10").Select
Selection.Cut
Range("A12:M12").Select
Selection.Cut

End Sub


Your help would be much appreciated.

Thanks

Brian


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Excel Macro code help - re pasting rows


Sub Move()

Dim ThisRow As Long ' row to copy
Dim FirstCol As Long ' first col of row
Dim LastCol As Long ' calculated last col
Dim Cols As Long ' width of row to be copied
Dim source As Range 'pointer to data to be copied
Dim target As Range ' pointer to range where data
will be copied

FirstCol = 1 ' A - SET as DEFAULT
Cols = 9 ' A...J SET AS DEFAULT
LastCol = FirstCol + Cols


ThisRow = Cells(65000, FirstCol).End(xlUp).Row

Do Until ThisRow <= 7

'set pointers to the source and target
Set target = Range(Cells(ThisRow - 1, LastCol +
1), Cells(ThisRow - 1, LastCol + 1 + Cols))
Set source = Range(Cells(ThisRow, FirstCol), Cells
(ThisRow, LastCol))

'copy the data
target.Value = source.Value

Rows(ThisRow).Delete

' get the next row
ThisRow = ThisRow - 2

Loop


End Sub

Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Hi I am trying to put data from two rows onto one row -

I have thousands of rows but I need help in coming up

with a way of
doing the job in bulk.

The code below represents what I want to do i.e. take

every even row
(starting at row 8) and paste it onto the end of the

previous row.


Sub Consol()

Range("A8:M8").Select
Selection.Cut
Range("A10:M10").Select
Selection.Cut
Range("A12:M12").Select
Selection.Cut

End Sub


Your help would be much appreciated.

Thanks

Brian


---
Message posted from http://www.ExcelForum.com/

.

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
Code to Unhide Rows using Macro Rajat Excel Worksheet Functions 7 January 14th 10 06:56 PM
Macro code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Macro/code to hide rows Smatass Excel Worksheet Functions 1 September 25th 07 01:57 AM
Copying and Pasting Rows Macro tnederlof Excel Discussion (Misc queries) 1 February 2nd 07 05:23 PM
How to code Macro for hiding rows Catherine Bond Excel Worksheet Functions 4 June 24th 06 10:13 AM


All times are GMT +1. The time now is 06:11 AM.

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"