Simple Code Debugging

MrCameronExcel

New Member
Joined
Apr 21, 2017
Messages
43
Office Version
  1. 365
Platform
  1. Windows
Hi MrExcel users,

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

(https://www.youtube.com/watch?v=S55...Hv2ztGjIkrW7suD6oNDaOk3vbR&index=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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
It might help if you stated where it is "bugging" out and what the error message states.
 
Upvote 0
Actually I can see 1 error.
It is xlUp not x1Up (a lower case L).
 
Upvote 0
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
 
Upvote 0
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 :biggrin:).
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top