Kamis, 19 Januari 2017

Re: [ExcelVBA] cut and paste cells with code

 

Thanks Paul,

I came up with this after looking at some other examples and playing around with it, works beautifully!
Columns D and E contain values straight down to the last row of the data, anything not having a value in these columns is one of the subtotal rows which are staggered in Col B and C hence two If-Then loops. This allows my subtotal rows to be aligned in the same column and delete Columns A-C later in the routine. I so luv VBA for Excel!

lrow = Cells(Rows.Count, 19).End(xlUp).Row

    For i = lrow - 1 To 2 Step -1
    If Cells(i, 5) = "" Then
        Cells(i, 2).Cut Cells(i, 4)
    End If
    Next i
    
    For i = lrow - 1 To 2 Step -1
    If Cells(i, 4) = "" Then
        Cells(i, 3).Cut Cells(i, 4)
    End If
    Next i
    
    Cells(lrow - 1, 1).Cut Cells(lrow - 1, 4)

__._,_.___

Posted by: mgarza@fellowes.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar