Computing.Net > Forums > Office Software > Excel Macro; move row

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Macro; move row

Reply to Message Icon

Name: PelePro
Date: April 1, 2007 at 14:55:10 Pacific
OS: OS X 10.4.8
CPU/Ram: Dual 2GHz PPC G5 / 2gb
Product: Apple
Comment:

I am trying to make a macro that will move an entire row to another sheet based on a value of 1-4 in column G. For instance if colG=1 move to sheet 2 ... How would I go about this/



Sponsored Link
Ads by Google

Response Number 1
Name: rhawk7938
Date: April 2, 2007 at 18:01:16 Pacific
Reply:

Something like this:

Sub MvColumn()

If Range("E1") = 1 Then

Columns("E:E").Select
Selection.Cut
Sheets("Sheet2").Select
Columns("E:E").Select
ActiveSheet.Paste

End If

End Sub


0

Response Number 2
Name: DerbyDad03
Date: April 20, 2007 at 07:14:52 Pacific
Reply:

Sorry for the delayed reply, but...

If you avoid "selecting" items in VBA before performing an action on them, your code will typically run faster and be easier to follow. For example, the code above can be condensed down to a single line.

Sub MvColumn1()

If Sheets("Sheet1").Range("E1") = 1 Then Columns("E:E").Cut Destination:=Sheets("Sheet2").Range("E1")

End Sub


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


ben craddock 33 hiding Markup in word2003



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Macro; move row

Excel macro www.computing.net/answers/office/excel-macro/4051.html

Excel Macro - Seqentially # Rows www.computing.net/answers/office/excel-macro-seqentially-rows/6914.html

Excel Macro - Moving files www.computing.net/answers/office/excel-macro-moving-files/8006.html