+ Reply to Thread
Results 1 to 3 of 3

Thread: help fixing my macro from running multiple times

  1. #1
    Registered User
    Join Date
    11-18-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    1

    help fixing my macro from running multiple times

    I have some isssues with a macro that I am running. I have the following code:

    Dim r           As Range
        Dim cell        As Range
        Dim Nextrow     As Long
    
            Set r = Intersect(Target, Range("B10:W41"))
            If r Is Nothing Then Exit Sub
            
            ' Next available row
            Nextrow = Worksheets("Transition Sheet P-S").Range("A" & Rows.Count).End(xlUp).Row + 1
            
            For Each cell In r
                With cell.EntireRow
                    If UCase(.Range("M1").Text) = "YES" And _
                       WorksheetFunction.CountA(.Range("B1:V1")) = 21 Then
                            Worksheets("Transition Sheet P-S").Cells(Nextrow, "A").Resize(1, 21).Value = _
                                                                                  .Range("B1:X1").Value
                        Nextrow = Nextrow + 1
                    End If
                End With
            Next cell
    It keeps pasting the same row over and over if I click on that line again if I click back onto the row. I would like to maybe change the way the macro is being triggered can someone explain to me how to do this or show me code that will fix this issue?
    Last edited by MurseBry; 11-18-2010 at 07:13 PM. Reason: grammar

  2. #2
    Forum Guru Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,023

    Re: help fixing my macro from running multiple times

    Firstly you need to post ALL the code, what you think is important may not help, we need to see the code in its entirity including SUB and End Sub
    Not all forums are the same - seek and you shall find

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: help fixing my macro from running multiple times

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ 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.2.0