Results 1 to 3 of 3

Simple Code Debugging

This is a discussion on Simple Code Debugging within the Excel Questions forums, part of the Question Forums category; Hi MrExcel users, I am new to VBA , and am following along with a youtube channel to learn: ( ...

  1. #1
    New Member
    Join Date
    Apr 2017
    Posts
    1

    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
    7,752

    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
    7,752

    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

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