LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default how can I change rows of data around by code ??

I should mention that this code requires each region to have Column I
completely filled in (that is, no blank cells in Column I in each region).
That means you can't run the macro again until all "holes" in Column I's
data are filled back in. If you will need to run the code again before you
can fill all "holes" in Column I's data, then you need to tell me a column
that will always have *each* row of *each* region completely filled in and I
will change the code to use it as the determiner of where each region
starts.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Okay, try this code instead...

Sub ManipulateColumnI()
Dim X As Long
Dim FirstICell As Range
Dim RegionStartRows() As Long
Const StartOfDataRow As Long = 2
With Worksheets("Sheet6")
Set FirstICell = .Cells(StartOfDataRow, "I")
ReDim RegionStartRows(1 To 1)
RegionStartRows(1) = StartOfDataRow
Do
Set FirstICell = FirstICell.End(xlDown).End(xlDown)
If FirstICell.Row = .Rows.Count Then Exit Do
ReDim Preserve RegionStartRows(1 To UBound(RegionStartRows) + 1)
RegionStartRows(UBound(RegionStartRows)) = FirstICell.Row
Loop
For X = 1 To UBound(RegionStartRows)
Set FirstICell = .Cells(RegionStartRows(X), "I")
FirstICell.Offset(1).Value = FirstICell.Offset(1).Value & " " & _
FirstICell.Offset(2).Value
FirstICell.Offset(3).Resize(2).Copy FirstICell.Offset(2)
FirstICell.Offset(4).Resize(2).Clear
Next
End With
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Do not use this code... it will not work correctly. I'll be back shortly
with working code.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Give this macro a try (again, I would do it to a COPY of your worksheet
first)...

Sub ManipulateColumnI()
Dim FirstICell As Range
Const StartOfDataRow As Long = 2
With Worksheets("Sheet6")
Set FirstICell = .Cells(StartOfDataRow, "I")
Do
FirstICell.Offset(1).Value = FirstICell.Offset(1).Value & " " & _
FirstICell.Offset(2).Value
FirstICell.Offset(3).Resize(2).Copy FirstICell.Offset(2)
FirstICell.Offset(4).Resize(2).Clear
Set FirstICell = FirstICell.End(xlDown).End(xlDown)
Loop While FirstICell.Row < .Rows.Count
End With
End Sub

Don't forget to adjust the Worksheet name in the With statement and the
start row of your data in Column I in the Const statement (for the
StartOfDataRow constant).

--
Rick (MVP - Excel)


"colwyn" wrote in message
...

In each series in column I, I want to:

1. combine every second and third cell.

2. delete those cells formatted blue.(this is the final entry in each
set of data)

3. move every fourth and fifth cells up one row.


1
red
1760
102.97
101.16
1.02



2
red
2200
133.97
128.51
1.04

3
green
2200
127.70
127.66
1.00


4
black
1320
74.84
73.45
1.02

5
red
1320
72.83
73.45
0.99


6
blue
1320
71.87
73.45
0.98





Here's how I want it:

1
red 1760
102.97
101.16





2
red 2200
133.97
128.51



3
green 2200
127.70
127.66




4
black 1320
74.84
73.45



5
red 1320
72.83
73.45




6
blue 1320
71.87
73.45


--
colwyn
------------------------------------------------------------------------
colwyn's Profile:
http://www.thecodecage.com/forumz/member.php?userid=34
View this thread:
http://www.thecodecage.com/forumz/sh...ad.php?t=41016





 
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
VBA code for moving data from even rows to columns after data in oddrows Steve G[_4_] Excel Programming 4 July 5th 08 05:26 PM
Worksheet change code to colour in rows in a database Peter Rooney Excel Programming 7 May 19th 06 11:36 AM
Need VBA code to dtermine how many rows have data in them Shani Excel Programming 4 April 13th 06 05:17 PM
Macro to add rows at a change in data Mr. T. Excel Programming 1 March 18th 06 02:25 PM
VBA code to Autofill one cell to many rows below where row count will change TrainingGoddess Excel Programming 5 March 28th 05 03:53 AM


All times are GMT +1. The time now is 09:35 AM.

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

About Us

"It's about Microsoft Excel"