Simple Code Debugging

MrCameronExcel

New Member
Joined
Apr 21, 2017
Messages
8
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
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,886
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
It might help if you stated where it is "bugging" out and what the error message states.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,886
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Actually I can see 1 error.
It is xlUp not x1Up (a lower case L).
 

MrCameronExcel

New Member
Joined
Apr 21, 2017
Messages
8
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
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,886
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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:).
 

Watch MrExcel Video

Forum statistics

Threads
1,123,133
Messages
5,599,912
Members
414,347
Latest member
tbanack

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
Top