Macro to move cells

B

BillyKit

I have a worksheet that contains rows of summary data determined b
dates in column A as in A2, A4,... and followed by one or more rows o
details data below it. Please, can someone help write a macro to mov
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
+-------------------------------------------------------------------
 
S

Simon Lloyd

BillyKit, you can attach a workbook in these forums

Attachments.

To upload a workbook, click reply then add your few words, scroll dow
past the submit button and you will see the Manage Attachments button
this is where you get to add files for upload, if you have any troubl
please use this link or the one at the bottom of th
any page.

BillyKit;590362 said:
I have a worksheet that contains rows of summary data determined b
dates in column A as in A2, A4,... and followed by one or more rows o
details data below it. Please, can someone help write a macro to mov
the details data to empty cells in the summary rows as lik


C3 to D2, E3 to F2, G3 to H2, I3 to J
C5 and c6 to D4 AND D6 respectively and so on..

Thank you

I have attach a file to make this clearer

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 
B

BillyKit

Simon said:
BillyKit, you can attach a workbook in these forums:

Attachments.

To upload a workbook, click reply then add your few words, scroll dow
past the submit button and you will see the Manage Attachments button
this is where you get to add files for upload, if you have any troubl
please use this link or the one at the bottom of th
any page.

I have attached a file in my question. Please let me know if there ar
more information required.
Thank yo
 
P

Patrick Molloy

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
 
B

BillyKit

Patrick said:
thecodecage requires a user login. sorry. won't do that to avoi
breaching
company policy.
try attaching file directly to the message -- some viewers like min
allow
them

Not to clear but I have paste the image here.

<b>Sheet1</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; " /><co
style="width:75px;" /><col style="width:47px;" /><co
style="width:64px;" /><col style="width:64px;" /><co
style="width:94px;" /><col style="width:64px;" /><co
style="width:64px;" /><col style="width:64px;" /><co
style="width:64px;" /><col style="width:64px;" /></colgroup><t
style="background-color:#cacaca; text-align:center; font-weight:bold
font-size:8pt; "> said:
D</td><td >E</td><td >F</td><td >G</td><td >H</td><td >I</td><t
J</td></tr><tr style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >1 said:
*</td><td >Qty</td><td >Item</td><td >Amount</td><td >Sku</td><t
Place</td><td >Qty1</td><td >Mode</td><td >Amount1</td></tr><t
style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >2</td><t
style="text-align:right; ">17-Dec-09</td><td >*</td><t
style="text-align:right; ">1 said:
*</td></tr><tr style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >3 said:
*</td><td style="text-align:right; ">123456</td><td >*</td><t
xxxxxxxxxx001</td><td >*</td><td style="text-align:right; ">1</td><t
*</td><td style="text-align:right; ">1.99</td><td >*</td></tr><t
style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >4</td><t
style="text-align:right; ">19-Dec-09</td><td >*</td><t
style="text-align:right; ">2 said:
*</td></tr><tr style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >5 said:
*</td><td style="text-align:right; ">111112</td><td >*</td><t
xxxxxxxxxx002</td><td >*</td><td style="text-align:right; ">1</td><t
*</td><td style="text-align:right; ">10</td><td >*</td></tr><t
style="height:18px ;" ><td style="font-size:8pt
background-color:#cacaca; text-align:center; " >6 said:
*</td><td style="text-align:right; ">111113</td><td >*</td><t
xxxxxxxxxx003</td><td >*</td><td style="text-align:right; ">1</td><t
*</td><td style="text-align:right; ">10</td><td >*</td></tr><t
style="height:18px ;" ><td style="font-size:8pt;
background-color:#cacaca; text-align:center; " >7 said:
*</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>
 
K

keiji kounoike

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
 
B

BillyKit

keiji said:
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

Thanks a lot, keiji . Finally ; you are a saviour. The code works great
and thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top