Simple Code Debugging

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Simple Code Debugging

  1. #1
    New Member
    Join Date
    Apr 2017
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Simple Code Debugging

     
    Hi MrExcel users,

    I am new to VBA, and am following along with a youtube channel to learn:

    (https://www.youtube.com/watch?v=S55c...x=8#t=0.576114)

    Although I am following his steps exactly, my VBA sheet needs bugging, and his does not. Is there something missing in my code - see below? Also, if you have any recommendations on how to self-teach Excel VBA, I would love to know how to best learn this language!

    Thank you


    Sub Test1()


    Dim mrsheet As Worksheet




    Set mrsheet = ThisWorkbook.Sheets("My Report")
    'Get last row of worksheet
    Lastrow = mrsheet.Cells(Rows.Count, 1).End(x1up).Row




    'Clears out last report
    mrsheet.Range("a2:c" & Lastrow).ClearContents




    For x = 2 To 500


    mrsheet.Cells(x, 1) = Date + 7


    mrsheet.Cells(x, 2) = x * 15

    If mrsheet.Cells(x, 2) > 100 Then
    mrsheet.Cells(x, 3) = True
    Else
    mrsheet.Cells(x, 3) = False
    End If

    Next x






    End Sub

  2. #2
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    8,812
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Simple Code Debugging

    It might help if you stated where it is "bugging" out and what the error message states.
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

  3. #3
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    8,812
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Simple Code Debugging

    Actually I can see 1 error.
    It is xlUp not x1Up (a lower case L).
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

  4. #4
    New Member
    Join Date
    Apr 2017
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Simple Code Debugging

    Quote Originally Posted by MARK858 View Post
    Actually I can see 1 error.
    It is xlUp not x1Up (a lower case L).
    Hi Mark,
    This was the solution! Thank you very much. Couldn't tell the difference when watching the video.
    It makes sense now, xlup meaning in the variable x, look up

  5. #5
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    8,812
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Simple Code Debugging

      
    Happy it helped (actually it is as simple as xl and Up as in the xl is just short for Excel and used in most parameters ).
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com