Posted to microsoft.public.excel.programming
|
|
Macro to move cells
keiji kounoike;591997 Wrote:
I 'm not sure what "*" and "*" mean in your image described below, so
this might not be what you want. But try this one.
Sub MoveCelltest()
Dim fcell As Range, ncell As Range
Dim frow As Long, lastrow As Long, i As Long
frow = 2
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Set fcell = Cells(frow, "A")
Set ncell = fcell.Offset(1, 0)
Do While (frow <= lastrow)
If fcell = ncell Or IsDate(fcell) And Not IsDate(ncell) _
Or ncell = "" Then
nrow = ncell.Row
Cells(frow, "D") = Cells(nrow, "C")
Cells(nrow, "C") = ""
Cells(frow, "F") = Cells(nrow, "E")
Cells(nrow, "E") = ""
Cells(frow, "H") = Cells(nrow, "G")
Cells(nrow, "G") = ""
Cells(frow, "J") = Cells(nrow, "I")
Cells(nrow, "I") = ""
Set ncell = ncell.Offset(1, 0)
frow = nrow
Else
Set fcell = ncell
Set ncell = fcell.Offset(1, 0)
frow = fcell.Row
End If
Loop
End Sub
Keiji
BillyKit wrote:
Patrick Molloy;590548 Wrote:
thecodecage requires a user login. sorry. won't do that to avoid
breaching
company policy.
try attaching file directly to the message -- some viewers like
mine
allow
them
"BillyKit" wrote in message
...
I have a worksheet that contains rows of summary data determined
by
dates in column A as in A2, A4,... and followed by one or more
rows
of
details data below it. Please, can someone help write a macro to
move
the details data to empty cells in the summary rows as like
C3 to D2, E3 to F2, G3 to H2, I3 to J2
C5 and c6 to D4 AND D6 respectively and so on...
Thank you
I have attach a file to make this clearer.
+-------------------------------------------------------------------+
|Filename: excel_help1.JPG
|
|Download:
http://www.thecodecage.com/forumz/attachment.php?attachmentid=389|
+-------------------------------------------------------------------+
--
BillyKit
------------------------------------------------------------------------
BillyKit's Profile: 1313
View this thread:
'Macro to move cells - The Code Cage Forums'
('Macro to move cells - The Code Cage Forums'
(http://www.thecodecage.com/forumz/sh....php?t=163596))
'Microsoft Office Help' ("http://www.thecodecage.com")
Not to clear but I have paste the image here.
<bSheet1</b<br /<br /<table border="1" cellspacing="0"
cellpadding="0" style="font-family:Calibri,Arial; font-size:11pt;
background-color:#ffffff; padding-left:2pt; padding-right:2pt; "
<colgroup<col style="font-weight:bold; width:30px; " /<col
style="width:75px;" /<col style="width:47px;" /<col
style="width:64px;" /<col style="width:64px;" /<col
style="width:94px;" /<col style="width:64px;" /<col
style="width:64px;" /<col style="width:64px;" /<col
style="width:64px;" /<col style="width:64px;" /</colgroup<tr
style="background-color:#cacaca; text-align:center;
font-weight:bold;
font-size:8pt; "<td *</td<td A</td<td B</td<td C</td<td
D</td<td E</td<td F</td<td G</td<td H</td<td I</td<td
J</td</tr<tr style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 1</td<td
Date</td<td
*</td<td Qty</td<td Item</td<td Amount</td<td Sku</td<td
Place</td<td Qty1</td<td Mode</td<td Amount1</td</tr<tr
style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 2</td<td
style="text-align:right; "17-Dec-09</td<td *</td<td
style="text-align:right; "1</td<td *</td<td
style="text-align:right;
"1.99</td<td *</td<td Loc1</td<td *</td<td Cash</td<td
*</td</tr<tr style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 3</td<td *</td<td
*</td<td style="text-align:right; "123456</td<td *</td<td
xxxxxxxxxx001</td<td *</td<td style="text-align:right;
"1</td<td
*</td<td style="text-align:right; "1.99</td<td *</td</tr<tr
style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 4</td<td
style="text-align:right; "19-Dec-09</td<td *</td<td
style="text-align:right; "2</td<td *</td<td
style="text-align:right;
"20</td<td *</td<td Loc2</td<td *</td<td Visa </td<td
*</td</tr<tr style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 5</td<td *</td<td
*</td<td style="text-align:right; "111112</td<td *</td<td
xxxxxxxxxx002</td<td *</td<td style="text-align:right;
"1</td<td
*</td<td style="text-align:right; "10</td<td *</td</tr<tr
style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 6</td<td *</td<td
*</td<td style="text-align:right; "111113</td<td *</td<td
xxxxxxxxxx003</td<td *</td<td style="text-align:right;
"1</td<td
*</td<td style="text-align:right; "10</td<td *</td</tr<tr
style="height:18px ;" <td style="font-size:8pt;
background-color:#cacaca; text-align:center; " 7</td<td
style="text-align:right; "20-Dec-09</td<td *</td<td *</td<td
*</td<td *</td<td *</td<td *</td<td *</td<td *</td<td
*</td</tr</table <br /<br /<span style="font-family:Arial;
font-size:9pt; font-weight:bold;background-color:#ffffff;
color:#000000;
"Excel tables to the web </span<a style ="font-family:Arial;
font-size:9pt; color:#fcf507; background-color:#800040;
font-weight:bold;"
href="http://www.excel-jeanie-html.de/index.php?f=1"
target="_blank" Excel Jeanie HTML 4 </a
Thanks a lot, keiji . Finally ; you are a saviour. The code works great
and thanks again.
--
BillyKit
------------------------------------------------------------------------
BillyKit's Profile: 1313
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=163596
Microsoft Office Help
|