+ Reply to Thread
Results 1 to 2 of 2

Adding conditions and variables to lengthy code

Hybrid View

  1. #1
    Registered User
    Join Date
    02-03-2011
    Location
    Illinois, United States
    MS-Off Ver
    Excel 2010
    Posts
    1

    Post Adding conditions and variables to lengthy code

    Hey everyone! I'm fairly new to coding, especially in Excel, and I want to code a bit a grunt work so I wouldn't have to do it. Here are some example snippets of my code:

    Sub MoveScores()
    Range("A2").Cut Destination:=Range("B1")
    Range("A4").Cut Destination:=Range("B3")
    ...........
    Range("A52").Cut Destination:=Range("B51")
    Range("A54").Cut Destination:=Range("B53")
    End Sub
    Rows("3:5").Select
    Selection.Delete Shift:=xlUp
    ...........
    Rows("53:55").Select
    Selection.Delete Shift:=xlUp
    These macros are effective but, as you can see, terribly inefficient. They also have no variance for the length of the document etc. I tried coding these using a While statement, but it just didn't work out.

    Can anybody help me improve my code? I would be very grateful!
    Last edited by scowalt; 02-03-2011 at 10:45 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Adding conditions and variables to lengthy code

    Sub MoveScores()
    Range("B1")=Range("A2")
    
    End Sub
    Rows("3:5").Delete Shift:=xlUp
    Maybe supply a sample workbook showing what you want accomplished

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1