close

I have a macro as follows:
Sub Macro2()
ActiveCell.Offset(-1, 0).Range(quot;A1quot;).Select
Selection.Hyperlinks.Delete
Selection.Cut
ActiveCell.Offset(-1, 1).Range(quot;A1quot;).Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Rows(quot;1:2quot;).EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(2, 0).Range(quot;A1quot;).Select
End Sub

It selects the above cell. Remove the hyperlink, moves it to top-right
cell, selects two rows and delete them and sits in the two rows below
same cell as started and ready to do this task again. I have many lins
to do this task and if I want to repeat the macro for each loop it
takes long long time. I want Macro to do all for me.
I want to put this Macro in a loop to do these tasks as long as there
is a row below and stops when it reaches the last row.
How can I make the loop in this macro?
TIA, Rasoul Khoshravanif your layout is as shown this macro will do
data
hyperlink
data
hyperlink

I didn't know which column so I used the active column
Sub macro2b()'works
ac = ActiveCell.Column
lr = Cells(Rows.Count, ac).End(xlUp).Row
For i = lr To 2 Step -2
Cells(i - 1, ac 1).Value = Cells(i, ac)
Rows(i).Delete
Next i
End Sub

--
Don Guillett
SalesAid Software

quot;Khoshravanquot; gt; wrote in message oups.com...
gt;I have a macro as follows:
gt; Sub Macro2()
gt; ActiveCell.Offset(-1, 0).Range(quot;A1quot;).Select
gt; Selection.Hyperlinks.Delete
gt; Selection.Cut
gt; ActiveCell.Offset(-1, 1).Range(quot;A1quot;).Select
gt; ActiveSheet.Paste
gt; ActiveCell.Offset(1, 0).Rows(quot;1:2quot;).EntireRow.Select
gt; Selection.Delete Shift:=xlUp
gt; ActiveCell.Offset(2, 0).Range(quot;A1quot;).Select
gt; End Sub
gt;
gt; It selects the above cell. Remove the hyperlink, moves it to top-right
gt; cell, selects two rows and delete them and sits in the two rows below
gt; same cell as started and ready to do this task again. I have many lins
gt; to do this task and if I want to repeat the macro for each loop it
gt; takes long long time. I want Macro to do all for me.
gt; I want to put this Macro in a loop to do these tasks as long as there
gt; is a row below and stops when it reaches the last row.
gt; How can I make the loop in this macro?
gt; TIA, Rasoul Khoshravan
gt;
A second option would be to assign the macro a short cut key (I like control
quot;qquot;) and add

SendKeys (quot;^qquot;)

to the end of the query. It will keep running until you hit pause/break.

quot;Khoshravanquot; wrote:

gt; I have a macro as follows:
gt; Sub Macro2()
gt; ActiveCell.Offset(-1, 0).Range(quot;A1quot;).Select
gt; Selection.Hyperlinks.Delete
gt; Selection.Cut
gt; ActiveCell.Offset(-1, 1).Range(quot;A1quot;).Select
gt; ActiveSheet.Paste
gt; ActiveCell.Offset(1, 0).Rows(quot;1:2quot;).EntireRow.Select
gt; Selection.Delete Shift:=xlUp
gt; ActiveCell.Offset(2, 0).Range(quot;A1quot;).Select
gt; End Sub
gt;
gt; It selects the above cell. Remove the hyperlink, moves it to top-right
gt; cell, selects two rows and delete them and sits in the two rows below
gt; same cell as started and ready to do this task again. I have many lins
gt; to do this task and if I want to repeat the macro for each loop it
gt; takes long long time. I want Macro to do all for me.
gt; I want to put this Macro in a loop to do these tasks as long as there
gt; is a row below and stops when it reaches the last row.
gt; How can I make the loop in this macro?
gt; TIA, Rasoul Khoshravan
gt;
gt;

Thanks for you reply but I am a beginner in MAcro so I almost couldn't
understand what does your Macro do. I copy paste it my Excel work book
but it didn't produce my requested results.You did not say what the problem is. I said, IF your layout is as shown, it
will work. What is your layout? Send me a workbook (to email below) and I
will take a look.

--
Don Guillett
SalesAid Software

quot;Khoshravanquot; gt; wrote in message oups.com...
gt; Thanks for you reply but I am a beginner in MAcro so I almost couldn't
gt; understand what does your Macro do. I copy paste it my Excel work book
gt; but it didn't produce my requested results.
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()