+ Reply to Thread
Results 1 to 9 of 9

On Error Message

  1. #1
    Registered User
    Join Date
    11-12-2013
    Location
    Woodford, Essex
    MS-Off Ver
    Excel 2007
    Posts
    4

    Angry On Error Message

    I am a new member and a complete novice where VBA is concerned. I have tried to resolve this issue but am now struggling. When I run my code if it fails to find what it is looking for I get an error message. I want it to return a message directing the user to enter "Comp" in the cell correcly. Can anyone assist here?

    Please Login or Register  to view this content.
    Last edited by arlu1201; 11-13-2013 at 06:16 AM. Reason: Corrected code tags.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: On Error Message

    May be this......

    Please Login or Register  to view this content.
    Last edited by sktneer; 11-13-2013 at 07:06 AM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: On Error Message

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-12-2013
    Location
    Woodford, Essex
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: On Error Message

    Hi Yudlugar
    Many thanks for your resolution to my problem but I am a novice here and have no idea where to place your code in mine. I am sorry to be a pain

    Peter

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: On Error Message

    Peter, replace your code with mine.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: On Error Message

    Also, you could make a loop to do this for all rows with comp in, that might be better?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-12-2013
    Location
    Woodford, Essex
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: On Error Message

    Hi Yudlugar

    The code below seems to be cutting and pasting both the row in which "Comp" is found and the cell the active cell from where the macro was started. It needs to just cut and paste the row on which "Comp" is found and shift all the rows below up.

    Really sorry to continue to be a pain but your help is very much appreciated

    Peter

    [Sub CompVoid()
    Dim rng
    Set rng = Cells.Find(what:="Comp", After:=ActiveCell, LookIn:=xlFormulas, lookat _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    True, SearchFormat:=False).Activate
    If rng Is Nothing Then
    MsgBox "Enter Comp in cell correctly"
    Exit Sub
    Else
    Do Until rng Is Nothing
    Rows(rng.Row).Cut Sheets("CompVoids").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Sheets("LiveVoids").Select
    Selection.Delete shift:=xlUp
    Set rng = Cells.FindNext(rng)
    Loop
    End If
    End Sub]

  8. #8
    Registered User
    Join Date
    11-12-2013
    Location
    Woodford, Essex
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: On Error Message

    Hi Yudlugar

    This code is great although there is one snag. When the search finds "Comp" it does not activate that cell and subsequently the delete command deletes both row and the cell that is currently active (basically the active cell where the code was ran from)

    Peter

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: On Error Message

    Sorry, I don't understand. Please can you upload an example workbook, click go advanced and then manage attachments. If you could include a brief description of what the macro is supposed to do that would be helpful.

  10. #10
    Registered User
    Join Date
    11-12-2013
    Location
    Woodford, Essex
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: On Error Message

    Yudlugar

    I have attached the workbook as requested.

    The idea here is that the LiveVoids sheet contains the list of all properties where repair works are ongoing. Once complete each property can be identified by entering "Comp" in the first column in the appropriate row. I then want the macro to pick up any row identified as complete ("Comp")and move it to the CompVoids sheet at the next available blank row.

    I hope this helps

    And once again many thanks for your valuable assistance

    Peter

+ 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. An error message on open - a totally blank VBA message box
    By Mr_Tigas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2013, 11:29 AM
  2. Error Message For Function Procedure WITHOUT using a message box
    By bmr8002 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2012, 02:01 PM
  3. Replacing run time error message with a different message
    By penny in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-14-2009, 10:51 AM
  4. replace VBA run-time error message with custom message
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-14-2006, 11: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