+ Reply to Thread
Results 1 to 7 of 7

VBA Code Issue

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question VBA Code Issue

    Can anybody explain to me what is incorrect about the following code as I keep getting "Compile Error: Loop without Do" message:

    Sub RemoveSalesReps()
    '


    'Do
    DoEvents
    row_number = row_number + 1
    Z1_Sales_Rep = GTCalc.Range("n" & row_number)
    If InStr(Z1_Sales_Rep, "MR X") >= 1 Then
    GTCalc.Rows(row_number & ":" & row_number).Delete
    row_number = row_number - 1

    Loop Until Z1_Sales_Rep = ""
    MsgBox "Complete"
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Code Issue

    You are missing an End If.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code Issue

    Hi Norie,

    Unfortunately this hasn't solved my problem as I get the same error message but now Loop Until is highlighted in blue?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Code Issue

    Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    07-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code Issue

    Please Login or Register  to view this content.
    Apologies is this now correct?
    Last edited by billybea; 09-22-2015 at 04:43 AM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Code Issue

    The code I posted compiles and will run, when exactly are you getting an error and what is the error message?

  7. #7
    Registered User
    Join Date
    07-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code Issue

    Hi Norie,

    There were two issues with my code. One being the starting position and the other being the sheet name:
    Please Login or Register  to view this content.
    Thank You for your guidance

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code Compatibility Issue from 32 to 64 bit
    By gaikwad.mm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2015, 04:21 AM
  2. [SOLVED] Password code designed for 5 Users - NAVIGATION Help Needed! - CODE Issue!
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-09-2014, 10:46 AM
  3. Vba username code issue
    By rebel_yell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2014, 09:23 AM
  4. [SOLVED] Macro code Issue!
    By Chrispylcfc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-06-2013, 03:29 PM
  5. [SOLVED] Issue - Selecting Code
    By Domski in forum Suggestions for Improvement
    Replies: 30
    Last Post: 04-13-2012, 06:37 AM
  6. Calculation VB Code Issue
    By hedge in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-21-2009, 05:40 PM
  7. Replies: 0
    Last Post: 10-06-2006, 09:05 AM

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